Module: Clickhouse::Connection::Client
- Includes:
- ActiveSupport::NumberHelper
- 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
6 7 8 |
# File 'lib/clickhouse/connection/client.rb', line 6 def connect! ping! unless connected? end |
#connected? ⇒ Boolean
21 22 23 |
# File 'lib/clickhouse/connection/client.rb', line 21 def connected? instance_variables.include?(:@client) && !!@client end |
#get(query) ⇒ Object
25 26 27 |
# File 'lib/clickhouse/connection/client.rb', line 25 def get(query) request(:get, query) end |
#ping! ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/clickhouse/connection/client.rb', line 10 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
29 30 31 |
# File 'lib/clickhouse/connection/client.rb', line 29 def post(query, body = nil) request(:post, query, body) end |
#url ⇒ Object
33 34 35 |
# File 'lib/clickhouse/connection/client.rb', line 33 def url "#{@config[:scheme]}://#{@config[:host]}:#{@config[:port]}" end |