Skip to content
Snippets Groups Projects

Add experimental ClickHouse HTTP client

Merged Adam Hegyi requested to merge ah-clickhouse-client-experiment into master
2 unresolved threads
Compare and Show latest version
15 files
+ 379
47
Compare changes
  • Side-by-side
  • Inline
Files
15
# frozen_string_literal: true
Gitlab::ClickHouse::Client.configure do |c|
c.add_database(:main,
database: 'gitlab_clickhouse_test',
url: 'http://localhost:8123',
username: 'default',
password: 'clickhouse'
)
return unless File.exist?(Rails.root.join('config/click_house.yml'))
c.json_parser = Gitlab::Json
c.http_call_proc = ->(url, headers, body) do
raw_config = Rails.application.config_for(:click_house)
return if raw_config.blank?
Gitlab::ClickHouse::Client.configure do |config|
raw_config.each do |database_identifier, db_config|
config.register_database(database_identifier,
database: db_config[:database],
url: db_config[:url],
username: db_config[:username],
password: db_config[:password],
variables: db_config[:variables] || {}
)
end
config.json_parser = Gitlab::Json
config.http_post_proc = ->(url, headers, body) do
options = {
headers: headers,
body: body,
allow_local_requests: true
allow_local_requests: Rails.env.development? || Rails.env.test?
}
Gitlab::HTTP.post(url, options)
response = Gitlab::HTTP.post(url, options)
Gitlab::ClickHouse::Client::Response.new(response.body, response.code)
end
end
Loading