clickhouse-native 0.2.1 → 0.3.1
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 +22 -2
- data/lib/clickhouse_native/version.rb +1 -1
- metadata +4 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: cbf19153b9c176c74fb8f20afb63e729234e03d3c8603b68746c474cabd53fe4
|
|
4
|
+
data.tar.gz: a8400e1c62470dce319fd655e4fa90a930848e1e76134cc2dec02c978b6fb011
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d48367dcae10c7921dfd2021a8e99af178e97708a314f15d3c30a38c33118ba027e47fc8eef2a5eaa60f3c257a2f6ecb6c2b48565cfa045d23f79da77691026d
|
|
7
|
+
data.tar.gz: 7080239fb14c0b7e1a0787942ea1a000749d36732744253dd9d1c7705bafea055970efb0a7f0163b480282b92b9e6abe520a36f044db8cf609b0de4587b50930
|
|
@@ -7,13 +7,17 @@ module ClickhouseNative
|
|
|
7
7
|
attr_reader :host, :port, :database
|
|
8
8
|
|
|
9
9
|
def initialize(host:, port:, database: "default", user: "default", password: "",
|
|
10
|
-
compression: :none, logger: nil,
|
|
10
|
+
compression: :none, logger: nil, settings: {},
|
|
11
|
+
pool_size: 5, pool_timeout: 5)
|
|
11
12
|
@host = host
|
|
12
13
|
@port = port
|
|
13
14
|
@database = database
|
|
14
15
|
client_kwargs = { host:, port:, database:, user:, password:, compression:, logger: }
|
|
16
|
+
set_sql = settings_sql(settings)
|
|
15
17
|
@pool = ConnectionPool.new(size: pool_size, timeout: pool_timeout) do
|
|
16
|
-
Client.new(**client_kwargs)
|
|
18
|
+
client = Client.new(**client_kwargs)
|
|
19
|
+
client.execute(set_sql) if set_sql
|
|
20
|
+
client
|
|
17
21
|
end
|
|
18
22
|
end
|
|
19
23
|
|
|
@@ -52,5 +56,21 @@ module ClickhouseNative
|
|
|
52
56
|
def describe_table(table, db_name: nil)
|
|
53
57
|
@pool.with { |c| c.describe_table(table, db_name:) }
|
|
54
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
|
|
55
75
|
end
|
|
56
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.1
|
|
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,10 @@ files:
|
|
|
292
291
|
- lib/clickhouse_native/logging.rb
|
|
293
292
|
- lib/clickhouse_native/pool.rb
|
|
294
293
|
- lib/clickhouse_native/version.rb
|
|
295
|
-
homepage:
|
|
294
|
+
homepage: https://github.com/umbrellio/clickhouse-native
|
|
296
295
|
licenses:
|
|
297
296
|
- Apache-2.0
|
|
298
297
|
metadata: {}
|
|
299
|
-
post_install_message:
|
|
300
298
|
rdoc_options: []
|
|
301
299
|
require_paths:
|
|
302
300
|
- lib
|
|
@@ -311,8 +309,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
311
309
|
- !ruby/object:Gem::Version
|
|
312
310
|
version: '0'
|
|
313
311
|
requirements: []
|
|
314
|
-
rubygems_version:
|
|
315
|
-
signing_key:
|
|
312
|
+
rubygems_version: 4.0.6
|
|
316
313
|
specification_version: 4
|
|
317
314
|
summary: ClickHouse Ruby driver over the native TCP protocol
|
|
318
315
|
test_files: []
|