pinot-client 1.4.0 → 1.5.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/README.md +4 -0
- data/lib/pinot/config.rb +26 -1
- data/lib/pinot/connection.rb +5 -3
- data/lib/pinot/connection_factory.rb +2 -0
- data/lib/pinot/instrumentation.rb +36 -0
- data/lib/pinot/version.rb +1 -1
- data/lib/pinot.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bb872f6cbcc1f34f16a68006eac8acea39229bdc9bd90f9f44a3369ed9c9fb59
|
|
4
|
+
data.tar.gz: b86cde24abaa6343f9984b3106830e9f00e25656050a4f577629942c3e0067c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: afc088a4df6eaa77e6141fa051d7f2e1f3afa1aa8d75555ed2291dfc84fe159a9538ad86621d452bc510066576a331d6e23135aa93529f672bf912ba46ed5b0c
|
|
7
|
+
data.tar.gz: b34bcb378ab7a6bca383545b79e090273ed0b67d4e5356699461b02bbbaaafd7e7580073e492bbb7f43cf988c77ba500e361e1954c53a990aab5be6d785cae4b
|
data/README.md
CHANGED
|
@@ -277,6 +277,10 @@ Environment variables:
|
|
|
277
277
|
| `BROKER_HOST` | `127.0.0.1` | Pinot broker hostname |
|
|
278
278
|
| `BROKER_PORT` | `8000` | Pinot broker HTTP port |
|
|
279
279
|
|
|
280
|
+
## Changelog
|
|
281
|
+
|
|
282
|
+
See [CHANGELOG.md](CHANGELOG.md) for a full history of releases.
|
|
283
|
+
|
|
280
284
|
## License
|
|
281
285
|
|
|
282
286
|
Apache License 2.0 — see [LICENSE](LICENSE).
|
data/lib/pinot/config.rb
CHANGED
|
@@ -20,13 +20,14 @@ module Pinot
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
class ClientConfig
|
|
23
|
-
attr_accessor :broker_list, :http_timeout, :extra_http_header,
|
|
23
|
+
attr_accessor :broker_list, :http_timeout, :query_timeout_ms, :extra_http_header,
|
|
24
24
|
:use_multistage_engine, :controller_config, :logger, :tls_config,
|
|
25
25
|
:grpc_config, :zookeeper_config
|
|
26
26
|
|
|
27
27
|
def initialize(
|
|
28
28
|
broker_list: [],
|
|
29
29
|
http_timeout: nil,
|
|
30
|
+
query_timeout_ms: nil,
|
|
30
31
|
extra_http_header: {},
|
|
31
32
|
use_multistage_engine: false,
|
|
32
33
|
controller_config: nil,
|
|
@@ -37,6 +38,7 @@ module Pinot
|
|
|
37
38
|
)
|
|
38
39
|
@broker_list = broker_list
|
|
39
40
|
@http_timeout = http_timeout
|
|
41
|
+
@query_timeout_ms = query_timeout_ms
|
|
40
42
|
@extra_http_header = extra_http_header
|
|
41
43
|
@use_multistage_engine = use_multistage_engine
|
|
42
44
|
@controller_config = controller_config
|
|
@@ -45,5 +47,28 @@ module Pinot
|
|
|
45
47
|
@grpc_config = grpc_config
|
|
46
48
|
@zookeeper_config = zookeeper_config
|
|
47
49
|
end
|
|
50
|
+
|
|
51
|
+
def validate!
|
|
52
|
+
sources = [
|
|
53
|
+
!broker_list.empty?,
|
|
54
|
+
!controller_config.nil?,
|
|
55
|
+
!zookeeper_config.nil?,
|
|
56
|
+
!grpc_config.nil?
|
|
57
|
+
].count(true)
|
|
58
|
+
|
|
59
|
+
if sources == 0
|
|
60
|
+
raise ConfigurationError, "ClientConfig requires at least one of: broker_list, controller_config, zookeeper_config, or grpc_config"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
if !http_timeout.nil? && http_timeout <= 0
|
|
64
|
+
raise ConfigurationError, "http_timeout must be positive, got: #{http_timeout}"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
if !query_timeout_ms.nil? && query_timeout_ms <= 0
|
|
68
|
+
raise ConfigurationError, "query_timeout_ms must be positive, got: #{query_timeout_ms}"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
self
|
|
72
|
+
end
|
|
48
73
|
end
|
|
49
74
|
end
|
data/lib/pinot/connection.rb
CHANGED
|
@@ -23,9 +23,11 @@ module Pinot
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def execute_sql(table, query)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
Pinot::Instrumentation.instrument(table: table, query: query) do
|
|
27
|
+
logger.debug "Executing SQL on table=#{table}: #{query}"
|
|
28
|
+
broker = @broker_selector.select_broker(table)
|
|
29
|
+
@transport.execute(broker, build_request(query))
|
|
30
|
+
end
|
|
29
31
|
rescue => e
|
|
30
32
|
raise "unable to execute SQL on table #{table}: #{e.message}"
|
|
31
33
|
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Pinot
|
|
2
|
+
module Instrumentation
|
|
3
|
+
# Called around every query execution.
|
|
4
|
+
# Implement by setting Pinot::Instrumentation.on_query = proc { |event| ... }
|
|
5
|
+
# event is a Hash:
|
|
6
|
+
# :table => String
|
|
7
|
+
# :query => String
|
|
8
|
+
# :duration_ms => Float
|
|
9
|
+
# :success => Boolean
|
|
10
|
+
# :error => Exception or nil
|
|
11
|
+
|
|
12
|
+
def self.on_query=(callback)
|
|
13
|
+
@on_query = callback
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.on_query
|
|
17
|
+
@on_query
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.instrument(table:, query:)
|
|
21
|
+
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
22
|
+
result = yield
|
|
23
|
+
duration_ms = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1000
|
|
24
|
+
notify(table: table, query: query, duration_ms: duration_ms, success: true, error: nil)
|
|
25
|
+
result
|
|
26
|
+
rescue => e
|
|
27
|
+
duration_ms = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - start) * 1000
|
|
28
|
+
notify(table: table, query: query, duration_ms: duration_ms, success: false, error: e)
|
|
29
|
+
raise
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.notify(event)
|
|
33
|
+
@on_query&.call(event)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
data/lib/pinot/version.rb
CHANGED
data/lib/pinot.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pinot-client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Xiang Fu
|
|
@@ -84,6 +84,7 @@ files:
|
|
|
84
84
|
- lib/pinot/errors.rb
|
|
85
85
|
- lib/pinot/grpc_config.rb
|
|
86
86
|
- lib/pinot/grpc_transport.rb
|
|
87
|
+
- lib/pinot/instrumentation.rb
|
|
87
88
|
- lib/pinot/logger.rb
|
|
88
89
|
- lib/pinot/prepared_statement.rb
|
|
89
90
|
- lib/pinot/proto/broker_service.proto
|