Class: ClickHouse::HTTPClient::Database
- Inherits:
-
Data
- Object
- Data
- ClickHouse::HTTPClient::Database
- Defined in:
- lib/clickhouse/http_client/database.rb
Overview
Connection settings and headers for one registered ClickHouse database.
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Class Method Summary collapse
Instance Method Summary collapse
-
#database_name ⇒ String
Physical ClickHouse database name.
-
#uri(extra_variables = {}) ⇒ URI::HTTP
Endpoint URI for this database.
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers
6 7 8 |
# File 'lib/clickhouse/http_client/database.rb', line 6 def headers @headers end |
#url ⇒ Object (readonly)
Returns the value of attribute url
6 7 8 |
# File 'lib/clickhouse/http_client/database.rb', line 6 def url @url end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables
6 7 8 |
# File 'lib/clickhouse/http_client/database.rb', line 6 def variables @variables end |
Class Method Details
.build(database:, url:, username:, password:, variables: {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/clickhouse/http_client/database.rb', line 7 def self.build(database:, url:, username:, password:, variables: {}) new( url: url, variables: { database: database, enable_http_compression: 1, # Buffer each response server-side before sending: without this, # ClickHouse commits HTTP 200 once it starts streaming, and an # error later in query execution (memory limit, server-side # timeout) is appended to the already-started body rather than # producing an error status. wait_end_of_query: 1, }.merge(variables).freeze, headers: { "X-ClickHouse-User" => username, "X-ClickHouse-Key" => password, "X-ClickHouse-Format" => "JSON", # always return JSON data }.freeze, ) end |
Instance Method Details
#database_name ⇒ String
Returns Physical ClickHouse database name.
29 30 31 |
# File 'lib/clickhouse/http_client/database.rb', line 29 def database_name variables.fetch(:database) end |
#uri(extra_variables = {}) ⇒ URI::HTTP
Returns Endpoint URI for this database.
35 36 37 38 39 |
# File 'lib/clickhouse/http_client/database.rb', line 35 def uri(extra_variables = {}) URI.parse(url).tap do |uri| uri.query = URI.encode_www_form(variables.merge(extra_variables)) end end |