clickhouse-native 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/clickhouse_native/pool.rb +27 -2
- data/lib/clickhouse_native/version.rb +1 -1
- metadata +3 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 86e2f9d658d26ab08d68e20e2ec860b3a55930dee07f196a009cbb9e046da665
|
|
4
|
+
data.tar.gz: fdc300bee85687032ca55517429da7c12581078bf9b54b914b2b781c93d58e12
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0fc100945686563388dd7e6c6655696788023f22f18559cf551e537815976808d4e3f582923447603c06b17559494a0b3d6be8f4d431d040c2c8862dd3ed3908
|
|
7
|
+
data.tar.gz: bfae8d96df41008a629fd814043c30d5b8147a37380c2ab3e7c7654fef3579d790128e2439809824afb22b9ed55e9ca3cbfd876ea71741e610e883181420031d
|
|
@@ -4,11 +4,20 @@ require "connection_pool"
|
|
|
4
4
|
|
|
5
5
|
module ClickhouseNative
|
|
6
6
|
class Pool
|
|
7
|
+
attr_reader :host, :port, :database
|
|
8
|
+
|
|
7
9
|
def initialize(host:, port:, database: "default", user: "default", password: "",
|
|
8
|
-
compression: :none, logger: nil,
|
|
10
|
+
compression: :none, logger: nil, settings: {},
|
|
11
|
+
pool_size: 5, pool_timeout: 5)
|
|
12
|
+
@host = host
|
|
13
|
+
@port = port
|
|
14
|
+
@database = database
|
|
9
15
|
client_kwargs = { host:, port:, database:, user:, password:, compression:, logger: }
|
|
16
|
+
set_sql = settings_sql(settings)
|
|
10
17
|
@pool = ConnectionPool.new(size: pool_size, timeout: pool_timeout) do
|
|
11
|
-
Client.new(**client_kwargs)
|
|
18
|
+
client = Client.new(**client_kwargs)
|
|
19
|
+
client.execute(set_sql) if set_sql
|
|
20
|
+
client
|
|
12
21
|
end
|
|
13
22
|
end
|
|
14
23
|
|
|
@@ -47,5 +56,21 @@ module ClickhouseNative
|
|
|
47
56
|
def describe_table(table, db_name: nil)
|
|
48
57
|
@pool.with { |c| c.describe_table(table, db_name:) }
|
|
49
58
|
end
|
|
59
|
+
|
|
60
|
+
private
|
|
61
|
+
|
|
62
|
+
# Render a `SET key1 = val1, key2 = val2` statement once at pool setup
|
|
63
|
+
# so every checked-out connection starts with the same session
|
|
64
|
+
# settings. Matches how the HTTP driver injected global_params per
|
|
65
|
+
# request. Values: Integer / Float render bare; anything else is
|
|
66
|
+
# quoted as a SQL string literal.
|
|
67
|
+
def settings_sql(settings)
|
|
68
|
+
return nil if settings.nil? || settings.empty?
|
|
69
|
+
parts = settings.map do |k, v|
|
|
70
|
+
literal = v.is_a?(Numeric) ? v.to_s : "'#{v.to_s.gsub("'", "''")}'"
|
|
71
|
+
"#{k} = #{literal}"
|
|
72
|
+
end
|
|
73
|
+
"SET #{parts.join(', ')}"
|
|
74
|
+
end
|
|
50
75
|
end
|
|
51
76
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: clickhouse-native
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yuri Smirnov
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: connection_pool
|
|
@@ -292,11 +291,9 @@ files:
|
|
|
292
291
|
- lib/clickhouse_native/logging.rb
|
|
293
292
|
- lib/clickhouse_native/pool.rb
|
|
294
293
|
- lib/clickhouse_native/version.rb
|
|
295
|
-
homepage:
|
|
296
294
|
licenses:
|
|
297
295
|
- Apache-2.0
|
|
298
296
|
metadata: {}
|
|
299
|
-
post_install_message:
|
|
300
297
|
rdoc_options: []
|
|
301
298
|
require_paths:
|
|
302
299
|
- lib
|
|
@@ -311,8 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
311
308
|
- !ruby/object:Gem::Version
|
|
312
309
|
version: '0'
|
|
313
310
|
requirements: []
|
|
314
|
-
rubygems_version:
|
|
315
|
-
signing_key:
|
|
311
|
+
rubygems_version: 4.0.6
|
|
316
312
|
specification_version: 4
|
|
317
313
|
summary: ClickHouse Ruby driver over the native TCP protocol
|
|
318
314
|
test_files: []
|