Class: ChConnect::Config
- Inherits:
-
Object
- Object
- ChConnect::Config
- Defined in:
- lib/ch_connect/config.rb
Overview
Configuration for ClickHouse connection.
Constant Summary collapse
- URL_SCHEMES =
{ "clickhouse" => false, "tcp" => false, "clickhouses" => true, "tcps" => true }.freeze
- DEFAULTS =
{ host: "localhost", port: nil, compression: :lz4, ssl: false, ssl_verify: true, ssl_ca: nil, database: "default", username: "default", password: "", connection_timeout: 5, read_timeout: 60, write_timeout: 60, keep_alive_timeout: 60, pool_size: 100, pool_timeout: 5, max_retries: 3, retry_base_interval: 0.05, retry_max_interval: 1.0, instrumenter: NullInstrumenter.new }.freeze
Instance Attribute Summary collapse
- #compression ⇒ String, ...
- #connection_timeout ⇒ String, ...
- #database ⇒ String, ...
- #host ⇒ String, ...
- #instrumenter ⇒ String, ...
- #keep_alive_timeout ⇒ String, ...
- #max_retries ⇒ String, ...
- #password ⇒ String, ...
- #pool_size ⇒ String, ...
- #pool_timeout ⇒ String, ...
-
#port ⇒ Object
Returns the explicitly configured port or the default for the active TLS mode.
- #read_timeout ⇒ String, ...
- #retry_base_interval ⇒ String, ...
- #retry_max_interval ⇒ String, ...
- #ssl ⇒ String, ...
- #ssl_ca ⇒ String, ...
- #ssl_verify ⇒ String, ...
- #username ⇒ String, ...
- #write_timeout ⇒ String, ...
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Config
constructor
Creates a new configuration instance.
-
#url=(url) ⇒ void
Sets configuration from a URL string.
Constructor Details
Instance Attribute Details
#compression ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def compression @compression end |
#connection_timeout ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def connection_timeout @connection_timeout end |
#database ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def database @database end |
#host ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def host @host end |
#instrumenter ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def instrumenter @instrumenter end |
#keep_alive_timeout ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def keep_alive_timeout @keep_alive_timeout end |
#max_retries ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def max_retries @max_retries end |
#password ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def password @password end |
#pool_size ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def pool_size @pool_size end |
#pool_timeout ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def pool_timeout @pool_timeout end |
#port ⇒ Object
Returns the explicitly configured port or the default for the active TLS mode.
96 97 98 |
# File 'lib/ch_connect/config.rb', line 96 def port @port || default_port end |
#read_timeout ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def read_timeout @read_timeout end |
#retry_base_interval ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def retry_base_interval @retry_base_interval end |
#retry_max_interval ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def retry_max_interval @retry_max_interval end |
#ssl ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def ssl @ssl end |
#ssl_ca ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def ssl_ca @ssl_ca end |
#ssl_verify ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def ssl_verify @ssl_verify end |
#username ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def username @username end |
#write_timeout ⇒ String, ...
65 66 67 |
# File 'lib/ch_connect/config.rb', line 65 def write_timeout @write_timeout end |
Instance Method Details
#url=(url) ⇒ void
This method returns an undefined value.
Sets configuration from a URL string.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/ch_connect/config.rb', line 104 def url=(url) uri = URI(url) ssl = URL_SCHEMES.fetch(uri.scheme) do raise ArgumentError, "unsupported ClickHouse URL scheme: #{uri.scheme.inspect}" end @ssl = ssl @port = uri.port @host = uri.host database = uri.path.delete_prefix("/") @database = database unless database.empty? @username = uri.user if uri.user @password = uri.password if uri.password end |