Module: Clickhouse::Connection::Client
- Included in:
- Clickhouse::Connection
- Defined in:
- lib/clickhouse/connection/client.rb
Instance Method Summary collapse
- #connect! ⇒ Object
- #connected? ⇒ Boolean
- #get(query) ⇒ Object
- #ping! ⇒ Object
- #post(query, body = nil) ⇒ Object
- #url ⇒ Object
Instance Method Details
#connect! ⇒ Object
5 6 7 |
# File 'lib/clickhouse/connection/client.rb', line 5 def connect! ping! unless connected? end |
#connected? ⇒ Boolean
20 21 22 |
# File 'lib/clickhouse/connection/client.rb', line 20 def connected? instance_variables.include?(:@client) && !!@client end |
#get(query) ⇒ Object
24 25 26 |
# File 'lib/clickhouse/connection/client.rb', line 24 def get(query) request(:get, query) end |
#ping! ⇒ Object
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/clickhouse/connection/client.rb', line 9 def ping! ensure_authentication status = client.get("/").status if status != 200 raise ConnectionError, "Unexpected response status: #{status}" end true rescue Faraday::Error => e raise ConnectionError, e. end |
#post(query, body = nil) ⇒ Object
28 29 30 |
# File 'lib/clickhouse/connection/client.rb', line 28 def post(query, body = nil) request(:post, query, body) end |
#url ⇒ Object
32 33 34 |
# File 'lib/clickhouse/connection/client.rb', line 32 def url "#{@config[:scheme]}://#{@config[:host]}:#{@config[:port]}" end |