Class: ClickHouse::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/click_house/config.rb

Constant Summary collapse

DEFAULTS =
{
  adapter: Faraday.default_adapter,
  url: nil,
  scheme: 'http',
  host: 'localhost',
  port: '8123',
  logger: nil,
  database: nil,
  username: nil,
  password: nil,
  timeout: nil,
  open_timeout: nil,
  ssl_verify: false,
  headers: {}
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) {|_self| ... } ⇒ Config

Returns a new instance of Config.

Yields:

  • (_self)

Yield Parameters:


35
36
37
38
# File 'lib/click_house/config.rb', line 35

def initialize(params = {})
  assign(DEFAULTS.merge(params))
  yield(self) if block_given?
end

Instance Attribute Details

#adapterObject

Returns the value of attribute adapter


21
22
23
# File 'lib/click_house/config.rb', line 21

def adapter
  @adapter
end

#databaseObject

Returns the value of attribute database


26
27
28
# File 'lib/click_house/config.rb', line 26

def database
  @database
end

#headersObject

Returns the value of attribute headers


33
34
35
# File 'lib/click_house/config.rb', line 33

def headers
  @headers
end

#hostObject

Returns the value of attribute host


24
25
26
# File 'lib/click_house/config.rb', line 24

def host
  @host
end

#loggerObject

Returns the value of attribute logger


22
23
24
# File 'lib/click_house/config.rb', line 22

def logger
  @logger
end

#open_timeoutObject

Returns the value of attribute open_timeout


31
32
33
# File 'lib/click_house/config.rb', line 31

def open_timeout
  @open_timeout
end

#passwordObject

Returns the value of attribute password


29
30
31
# File 'lib/click_house/config.rb', line 29

def password
  @password
end

#portObject

Returns the value of attribute port


25
26
27
# File 'lib/click_house/config.rb', line 25

def port
  @port
end

#schemeObject

Returns the value of attribute scheme


23
24
25
# File 'lib/click_house/config.rb', line 23

def scheme
  @scheme
end

#ssl_verifyObject

Returns the value of attribute ssl_verify


32
33
34
# File 'lib/click_house/config.rb', line 32

def ssl_verify
  @ssl_verify
end

#timeoutObject

Returns the value of attribute timeout


30
31
32
# File 'lib/click_house/config.rb', line 30

def timeout
  @timeout
end

#urlObject

Returns the value of attribute url


27
28
29
# File 'lib/click_house/config.rb', line 27

def url
  @url
end

#usernameObject

Returns the value of attribute username


28
29
30
# File 'lib/click_house/config.rb', line 28

def username
  @username
end

Instance Method Details

#assign(params = {}) ⇒ self

Returns:

  • (self)

41
42
43
44
45
# File 'lib/click_house/config.rb', line 41

def assign(params = {})
  params.each { |k, v| public_send("#{k}=", v) }

  self
end

#auth?Boolean

Returns:

  • (Boolean)

47
48
49
# File 'lib/click_house/config.rb', line 47

def auth?
  !username.nil? || !password.nil?
end

#logger!Object


51
52
53
# File 'lib/click_house/config.rb', line 51

def logger!
  @logger || null_logger
end

#null_loggerObject


59
60
61
# File 'lib/click_house/config.rb', line 59

def null_logger
  @null_logger ||= Logger.new(IO::NULL)
end

#url!Object


55
56
57
# File 'lib/click_house/config.rb', line 55

def url!
  @url || "#{scheme}://#{host}:#{port}"
end