chalk_ruby 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +0 -11
- data/lib/chalk_ruby/client.rb +134 -62
- data/lib/chalk_ruby/{config/config.rb → config.rb} +25 -8
- data/lib/chalk_ruby/defaults.rb +7 -7
- data/lib/chalk_ruby/helpers.rb +0 -1
- data/lib/chalk_ruby/http/http_requester.rb +5 -7
- data/lib/chalk_ruby/{transport/transport.rb → http/http_requester_chalk.rb} +3 -4
- data/lib/chalk_ruby/token.rb +18 -0
- data/lib/chalk_ruby/version.rb +1 -1
- data/lib/chalk_ruby.rb +2 -3
- data/sig/chalk_ruby/client.rbs +13 -4
- data/sig/chalk_ruby/{config/config.rbs → config.rbs} +9 -9
- data/sig/chalk_ruby/defaults.rbs +1 -1
- data/sig/chalk_ruby/{transport/transport.rbs → http/http_requester_chalk.rbs} +3 -3
- data/test/chalk_ai/integration/client_test.rb +2 -3
- metadata +7 -6
- /data/sig/chalk_ruby/{interfaces → http}/_connection.rbs +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 475cbc00a9b6c9a048e287fdca499ffd257a768c63471598c1db61d8a4757baf
|
4
|
+
data.tar.gz: bee580988929bc2219c4f6e6778e17eb8c2055ed80799be251d5af21295e32c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64ea24c0bc3d3ea81f2d32c72a7220c70a5e1c7e88a0dcef1c5907dbccbc40d4f9a9d6d91e1917359ec516c7a864b9ba3a57c2848c98f5dba83a2cf61c8f1d7e
|
7
|
+
data.tar.gz: f8821a753ba007213b63977d6a0b465944320e20d96728db4edd7e57a4a2aeb9b5f79ef2dc18ce5cfa29e648151a354d90061f19f7dd43a77c85c7bf0e28dfa5
|
data/.rubocop_todo.yml
CHANGED
@@ -1,14 +1,3 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2019-12-12 11:07:55 +0100 using RuboCop version 0.77.0.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 1
|
10
1
|
Style/Documentation:
|
11
2
|
Exclude:
|
12
|
-
- 'spec/**/*'
|
13
3
|
- 'test/**/*'
|
14
|
-
- 'lib/rubybundle/search_config.rb'
|
data/lib/chalk_ruby/client.rb
CHANGED
@@ -1,55 +1,36 @@
|
|
1
|
-
require 'chalk_ruby/config
|
1
|
+
require 'chalk_ruby/config'
|
2
2
|
require 'chalk_ruby/logger_helper'
|
3
|
-
require 'chalk_ruby/
|
3
|
+
require 'chalk_ruby/http/http_requester_chalk'
|
4
4
|
require 'chalk_ruby/http/response'
|
5
|
+
require 'chalk_ruby/token'
|
5
6
|
|
6
7
|
module ChalkRuby
|
7
|
-
class Token
|
8
|
-
attr_accessor :token, :expires_at, :environment, :engines
|
9
|
-
|
10
|
-
# @param [Hash[String, untyped]] exchange_credentials_response
|
11
|
-
def initialize(exchange_credentials_response)
|
12
|
-
@token = exchange_credentials_response[:access_token]
|
13
|
-
@expires_at = DateTime.parse(exchange_credentials_response[:expires_at])
|
14
|
-
@environment = exchange_credentials_response[:primary_environment]
|
15
|
-
@engines = exchange_credentials_response[:engines]
|
16
|
-
end
|
17
|
-
|
18
|
-
def expired?
|
19
|
-
DateTime.now.advance({ seconds: 60 }) > @expires_at
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
8
|
class Client
|
24
|
-
#
|
9
|
+
# Create a new client.
|
25
10
|
#
|
26
|
-
# @param
|
27
|
-
#
|
28
|
-
#
|
29
|
-
# @option http_requester [Object] http_requester object used for the connection
|
11
|
+
# @param client_id [String]
|
12
|
+
# Chalk client ID.
|
13
|
+
# If not provided, it will be read from the CHALK_CLIENT_ID environment variable.
|
30
14
|
#
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
adapter = opts[:adapter] || Defaults::ADAPTER
|
35
|
-
logger = opts[:logger] || LoggerHelper.create
|
36
|
-
requester = opts[:http_requester] || Defaults::REQUESTER_CLASS.new(adapter: adapter, logger: logger)
|
37
|
-
@transporter = Transport::Transport.new(requester: requester)
|
38
|
-
end
|
39
|
-
|
40
|
-
# Create a new client providing only app ID and API key
|
15
|
+
# @param client_secret [String]
|
16
|
+
# Chalk client secret.
|
17
|
+
# If not provided, it will be read from the CHALK_CLIENT_SECRET environment variable.
|
41
18
|
#
|
42
|
-
# @param
|
43
|
-
#
|
44
|
-
#
|
45
|
-
#
|
46
|
-
# @param
|
19
|
+
# @param environment [String]
|
20
|
+
# The Chalk environment id (not the name of the environment).
|
21
|
+
# If not provided, it will be read from the CHALK_ACTIVE_ENVIRONMENT environment variable.
|
22
|
+
#
|
23
|
+
# @param query_server [String]
|
24
|
+
# ChalkRuby query server
|
25
|
+
#
|
26
|
+
# @param api_server [String]
|
27
|
+
# ChalkRuby API server
|
47
28
|
#
|
48
29
|
# @return self
|
49
30
|
#
|
50
31
|
def self.create(
|
51
|
-
client_id,
|
52
|
-
client_secret,
|
32
|
+
client_id = nil,
|
33
|
+
client_secret = nil,
|
53
34
|
environment = nil,
|
54
35
|
query_server = nil,
|
55
36
|
api_server = nil
|
@@ -87,46 +68,137 @@ module ChalkRuby
|
|
87
68
|
# is defined on the `User` namespace, and all features on the `User` namespace
|
88
69
|
# (excluding has-one and has-many relationships) will be used as outputs.
|
89
70
|
#
|
71
|
+
# @param now [DateTime?]
|
72
|
+
# The time at which to evaluate the query. If not specified, the current time will be used.
|
73
|
+
# This parameter is complex in the context of online_query since the online store
|
74
|
+
# only stores the most recent value of an entity's features. If `now` is in the past,
|
75
|
+
# it is extremely likely that `None` will be returned for cache-only features.
|
76
|
+
#
|
77
|
+
# This parameter is primarily provided to support:
|
78
|
+
# - controlling the time window for aggregations over cached has-many relationships
|
79
|
+
# - controlling the time window for aggregations over has-many relationships loaded from an
|
80
|
+
# external database
|
81
|
+
#
|
82
|
+
# If you are trying to perform an exploratory analysis of past feature values, prefer `offline_query`.
|
83
|
+
#
|
84
|
+
# @param staleness [Hash[String, String]?]
|
85
|
+
# Maximum staleness overrides for any output features or intermediate features.
|
86
|
+
# See https://docs.chalk.ai/docs/query-caching for more information.
|
87
|
+
#
|
88
|
+
# @param tags [Hash[String, String]?]
|
89
|
+
# The tags used to scope the resolvers.
|
90
|
+
# See https://docs.chalk.ai/docs/resolver-tags for more information.
|
91
|
+
#
|
92
|
+
# @param branch [String?]
|
93
|
+
# If specified, Chalk will route your request to the relevant branch.
|
94
|
+
#
|
95
|
+
# @param correlation_id [String?]
|
96
|
+
# You can specify a correlation ID to be used in logs and web interfaces.
|
97
|
+
# This should be globally unique, i.e. a `uuid` or similar. Logs generated
|
98
|
+
# during the execution of your query will be tagged with this correlation id.
|
99
|
+
#
|
100
|
+
# @param query_name [String?]
|
101
|
+
# The semantic name for the query you're making, for example, `"loan_application_model"`.
|
102
|
+
# Typically, each query that you make from your application should have a name.
|
103
|
+
# Chalk will present metrics and dashboard functionality grouped by 'query_name'.
|
104
|
+
#
|
105
|
+
# @param meta [Hash[String, String]?]
|
106
|
+
# Arbitrary `key:value` pairs to associate with a query.
|
107
|
+
#
|
108
|
+
# @param explain [Boolean?]
|
109
|
+
# Log the query execution plan. Requests using `explain=true` will be slower
|
110
|
+
# than requests using `explain=false`. If `"only"`, the query will not be executed,
|
111
|
+
# and only the query plan will be returned.
|
112
|
+
#
|
113
|
+
# If true, 'include_meta' will be set to true as well.
|
114
|
+
#
|
115
|
+
# @param include_meta [Boolean?]
|
116
|
+
# Whether to include metadata about the query execution.
|
117
|
+
#
|
118
|
+
# @param store_plan_stages [Boolean?]
|
119
|
+
# If `true`, the output of each of the query plan stages will be stored.
|
120
|
+
# This option dramatically impacts the performance of the query,
|
121
|
+
# so it should only be used for debugging.
|
90
122
|
#
|
91
123
|
# @return [Hash[Symbol, String]]
|
92
124
|
#
|
93
125
|
def query(
|
94
126
|
input:,
|
95
127
|
output:,
|
96
|
-
|
97
|
-
|
98
|
-
|
128
|
+
now: nil,
|
129
|
+
staleness: nil,
|
130
|
+
tags: nil,
|
131
|
+
branch: nil,
|
132
|
+
correlation_id: nil,
|
133
|
+
query_name: nil,
|
134
|
+
meta: nil,
|
135
|
+
explain: nil,
|
136
|
+
include_meta: nil,
|
137
|
+
store_plan_stages: nil
|
99
138
|
)
|
100
139
|
query_server_request(
|
101
140
|
method: :post,
|
102
141
|
path: 'v1/query/online',
|
103
142
|
body: {
|
104
143
|
inputs: input,
|
105
|
-
outputs: output
|
106
|
-
|
144
|
+
outputs: output,
|
145
|
+
now: now,
|
146
|
+
staleness: staleness,
|
147
|
+
context: tags && { tags: tags },
|
148
|
+
branch_id: branch,
|
149
|
+
correlation_id: correlation_id,
|
150
|
+
query_name: query_name,
|
151
|
+
meta: meta,
|
152
|
+
explain: explain || false,
|
153
|
+
include_meta: include_meta || false,
|
154
|
+
store_plan_stages: store_plan_stages || false
|
107
155
|
},
|
108
|
-
headers: get_authenticated_headers
|
156
|
+
headers: get_authenticated_headers(branch: branch)
|
109
157
|
)
|
110
158
|
end
|
111
159
|
|
112
160
|
def get_token
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
161
|
+
Token.new(
|
162
|
+
api_server_request(
|
163
|
+
method: :post,
|
164
|
+
path: '/v1/oauth/token',
|
165
|
+
body: {
|
166
|
+
client_id: @config.client_id,
|
167
|
+
client_secret: @config.client_secret,
|
168
|
+
grant_type: 'client_credentials'
|
169
|
+
},
|
170
|
+
headers: get_unauthenticated_headers
|
171
|
+
)
|
122
172
|
)
|
123
|
-
|
173
|
+
end
|
174
|
+
|
175
|
+
# Initializes the ChalkRuby client. Generally, you should not need to call this directly.
|
176
|
+
# Instead, use ChalkRuby::Client.create or ChalkRuby::Client.create_with_config.
|
177
|
+
#
|
178
|
+
# @param chalk_config [ChalkRuby::Config]
|
179
|
+
# A ChalkRuby::Config object which contains your CLIENT_ID and CLIENT_SECRET
|
180
|
+
#
|
181
|
+
# @option adapter [Object]
|
182
|
+
# Adapter object used for the connection
|
183
|
+
#
|
184
|
+
# @option logger [Object]
|
185
|
+
#
|
186
|
+
# @option http_requester [Object]
|
187
|
+
# object used for the connection
|
188
|
+
#
|
189
|
+
def initialize(chalk_config, opts = {})
|
190
|
+
@token = nil
|
191
|
+
@config = chalk_config
|
192
|
+
adapter = opts[:adapter] || Defaults::ADAPTER
|
193
|
+
logger = opts[:logger] || LoggerHelper.create
|
194
|
+
requester = opts[:http_requester] || Defaults::REQUESTER_CLASS.new(adapter: adapter, logger: logger)
|
195
|
+
@transporter = Http::HttpRequesterChalk.new(requester: requester)
|
124
196
|
end
|
125
197
|
|
126
198
|
private
|
127
199
|
|
128
200
|
def api_server_request(method:, path:, body:, headers:)
|
129
|
-
@transporter.
|
201
|
+
@transporter.send_request(
|
130
202
|
method: method,
|
131
203
|
host: @config.api_server,
|
132
204
|
path: path,
|
@@ -138,7 +210,7 @@ module ChalkRuby
|
|
138
210
|
end
|
139
211
|
|
140
212
|
def query_server_request(method:, path:, body:, headers:)
|
141
|
-
@transporter.
|
213
|
+
@transporter.send_request(
|
142
214
|
method: method,
|
143
215
|
host: query_server_host,
|
144
216
|
path: path,
|
@@ -149,13 +221,14 @@ module ChalkRuby
|
|
149
221
|
)
|
150
222
|
end
|
151
223
|
|
152
|
-
def get_authenticated_headers
|
224
|
+
def get_authenticated_headers(branch:)
|
153
225
|
t = valid_token
|
154
226
|
{
|
155
227
|
'Content-Type': 'application/json',
|
156
228
|
'Accept': 'application/json',
|
157
229
|
'Authorization': 'Bearer ' + t.token,
|
158
|
-
'X-
|
230
|
+
'X-Chalk-Env-Id': @config.environment || t.environment,
|
231
|
+
'X-Chalk-Branch-Id': branch
|
159
232
|
}
|
160
233
|
end
|
161
234
|
|
@@ -163,7 +236,7 @@ module ChalkRuby
|
|
163
236
|
{
|
164
237
|
'Content-Type': 'application/json',
|
165
238
|
'Accept': 'application/json',
|
166
|
-
'X-
|
239
|
+
'X-Chalk-Env-Id': @config.environment
|
167
240
|
}
|
168
241
|
end
|
169
242
|
|
@@ -187,6 +260,5 @@ module ChalkRuby
|
|
187
260
|
@token
|
188
261
|
end
|
189
262
|
end
|
190
|
-
|
191
263
|
end
|
192
264
|
end
|
@@ -12,14 +12,32 @@ module ChalkRuby
|
|
12
12
|
:api_timeout,
|
13
13
|
:connect_timeout
|
14
14
|
|
15
|
+
# Creates a new ChalkRuby::Config object for use with ChalkRuby::Client.
|
15
16
|
#
|
16
|
-
# @option options [String] :client_id
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
# @option options [
|
21
|
-
#
|
22
|
-
#
|
17
|
+
# @option options [String?] :client_id
|
18
|
+
# The Chalk client ID.
|
19
|
+
# If not provided, it will be read from the CHALK_CLIENT_ID environment variable.
|
20
|
+
#
|
21
|
+
# @option options [String?] :client_secret
|
22
|
+
# Chalk client secret.
|
23
|
+
# If not provided, it will be read from the CHALK_CLIENT_SECRET environment variable.
|
24
|
+
#
|
25
|
+
# @option options [String?] :query_host
|
26
|
+
# The query server to use.
|
27
|
+
# If not provided, it will be read from the CHALK_QUERY_SERVER environment variable.
|
28
|
+
#
|
29
|
+
# @option options [String?] :api_host
|
30
|
+
# The API server to use.
|
31
|
+
# If not provided, it will be read from the CHALK_API_SERVER environment variable.
|
32
|
+
#
|
33
|
+
# @option options [Integer?] :read_timeout
|
34
|
+
# The timeout for read operations (in seconds).
|
35
|
+
#
|
36
|
+
# @option options [Integer?] :write_timeout
|
37
|
+
# The timeout for write operations (in seconds).
|
38
|
+
#
|
39
|
+
# @option options [Integer?] :connect_timeout
|
40
|
+
# The timeout for connect operations (in seconds).
|
23
41
|
#
|
24
42
|
def initialize(opts = {})
|
25
43
|
@client_id = opts[:client_id] || ENV['CHALK_CLIENT_ID']
|
@@ -34,6 +52,5 @@ module ChalkRuby
|
|
34
52
|
raise ChalkError, 'No Client ID provided, please set :client_id' if @client_id.nil?
|
35
53
|
raise ChalkError, 'No Client Secret provided, please set :client_secret' if @client_secret.nil?
|
36
54
|
end
|
37
|
-
|
38
55
|
end
|
39
56
|
end
|
data/lib/chalk_ruby/defaults.rb
CHANGED
@@ -2,14 +2,14 @@ require 'chalk_ruby/http/http_requester'
|
|
2
2
|
|
3
3
|
module ChalkRuby
|
4
4
|
module Defaults
|
5
|
-
REQUESTER_CLASS =
|
5
|
+
REQUESTER_CLASS = Http::HttpRequester
|
6
6
|
ADAPTER = 'net_http_persistent'
|
7
7
|
|
8
8
|
# HTTP Headers
|
9
9
|
# ----------------------------------------
|
10
|
-
HEADER_CLIENT_ID = 'X-
|
11
|
-
HEADER_CLIENT_SECRET = 'X-
|
12
|
-
HEADER_ENVIRONMENT = 'X-
|
10
|
+
HEADER_CLIENT_ID = 'X-Chalk-Client-Id'.freeze
|
11
|
+
HEADER_CLIENT_SECRET = 'X-Chalk-Client-Secret'.freeze
|
12
|
+
HEADER_ENVIRONMENT = 'X-Chalk-Env-Id'.freeze
|
13
13
|
AUTHORIZATION_HEADER = 'Authorization'.freeze
|
14
14
|
USER_AGENT = "ChalkRuby Ruby (#{ChalkRuby::VERSION}), Ruby (#{RUBY_VERSION})"
|
15
15
|
|
@@ -27,9 +27,9 @@ module ChalkRuby
|
|
27
27
|
|
28
28
|
# HTTP TIMEOUTS
|
29
29
|
# ----------------------------------------
|
30
|
-
CONNECT_TIMEOUT =
|
31
|
-
API_TIMEOUT =
|
32
|
-
QUERY_TIMEOUT =
|
30
|
+
CONNECT_TIMEOUT = 100
|
31
|
+
API_TIMEOUT = 300
|
32
|
+
QUERY_TIMEOUT = 1200
|
33
33
|
|
34
34
|
WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY = 100
|
35
35
|
end
|
data/lib/chalk_ruby/helpers.rb
CHANGED
@@ -27,7 +27,7 @@ module ChalkRuby
|
|
27
27
|
# @param timeout [Integer]
|
28
28
|
# @param connect_timeout [Integer]
|
29
29
|
#
|
30
|
-
# @return [
|
30
|
+
# @return [Response]
|
31
31
|
#
|
32
32
|
def send_request(
|
33
33
|
host:,
|
@@ -57,24 +57,23 @@ module ChalkRuby
|
|
57
57
|
if ENV['CHALK_DEBUG']
|
58
58
|
@logger.info("Request succeeded. Response status: #{response.status}, body: #{response.body}")
|
59
59
|
end
|
60
|
-
return
|
60
|
+
return Response.new(status: response.status, body: response.body, headers: response.headers)
|
61
61
|
end
|
62
62
|
|
63
63
|
if ENV['CHALK_DEBUG']
|
64
64
|
@logger.info("Request failed. Response status: #{response.status}, error: #{response.body}")
|
65
65
|
end
|
66
|
-
|
66
|
+
Response.new(status: response.status, error: response.body, headers: response.headers)
|
67
67
|
rescue Faraday::TimeoutError => e
|
68
68
|
if ENV['CHALK_DEBUG']
|
69
69
|
@logger.info("Request timed out. Error: #{e.message}")
|
70
70
|
end
|
71
|
-
|
71
|
+
Response.new(error: e.message, has_timed_out: true)
|
72
72
|
rescue ::StandardError => e
|
73
73
|
if ENV['CHALK_DEBUG']
|
74
74
|
@logger.info("Request failed. Error: #{e.message}")
|
75
75
|
end
|
76
|
-
|
77
|
-
|
76
|
+
Response.new(error: e.message, network_failure: true)
|
78
77
|
end
|
79
78
|
|
80
79
|
# Retrieve the connection from the @connections
|
@@ -88,7 +87,6 @@ module ChalkRuby
|
|
88
87
|
f.adapter @adapter.to_sym
|
89
88
|
end
|
90
89
|
end
|
91
|
-
|
92
90
|
end
|
93
91
|
end
|
94
92
|
end
|
@@ -4,8 +4,8 @@ require 'faraday/net_http_persistent' unless Faraday::VERSION < '1'
|
|
4
4
|
require 'chalk_ruby/error'
|
5
5
|
|
6
6
|
module ChalkRuby
|
7
|
-
module
|
8
|
-
class
|
7
|
+
module Http
|
8
|
+
class HttpRequesterChalk
|
9
9
|
include Helpers
|
10
10
|
|
11
11
|
# @param requester [ChalkRuby::Http::HttpRequester] requester used for sending requests.
|
@@ -14,7 +14,7 @@ module ChalkRuby
|
|
14
14
|
@http_requester = requester
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
17
|
+
def send_request(method:, host:, path:, timeout:, connect_timeout:, headers:, body:)
|
18
18
|
response = @http_requester.send_request(
|
19
19
|
host: host,
|
20
20
|
method: method,
|
@@ -48,7 +48,6 @@ module ChalkRuby
|
|
48
48
|
def success?(http_response_code:)
|
49
49
|
!http_response_code.nil? && (http_response_code.to_i / 100).floor == 2
|
50
50
|
end
|
51
|
-
|
52
51
|
end
|
53
52
|
end
|
54
53
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module ChalkRuby
|
2
|
+
class Token
|
3
|
+
attr_accessor :token, :expires_at, :environment, :engines
|
4
|
+
|
5
|
+
# @param [Hash[String, untyped]] exchange_credentials_response
|
6
|
+
def initialize(exchange_credentials_response)
|
7
|
+
@token = exchange_credentials_response[:access_token]
|
8
|
+
@expires_at = DateTime.parse(exchange_credentials_response[:expires_at])
|
9
|
+
@environment = exchange_credentials_response[:primary_environment]
|
10
|
+
@engines = exchange_credentials_response[:engines]
|
11
|
+
end
|
12
|
+
|
13
|
+
def expired?
|
14
|
+
DateTime.now.advance({ seconds: 60 }) > @expires_at
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
data/lib/chalk_ruby/version.rb
CHANGED
data/lib/chalk_ruby.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
# ChalkRuby module
|
2
1
|
module ChalkRuby
|
3
2
|
require 'chalk_ruby/version'
|
4
3
|
require 'chalk_ruby/helpers'
|
5
4
|
require 'chalk_ruby/http/http_requester'
|
6
5
|
require 'chalk_ruby/defaults'
|
7
|
-
require 'chalk_ruby/config
|
6
|
+
require 'chalk_ruby/config'
|
8
7
|
require 'chalk_ruby/http/response'
|
9
|
-
require 'chalk_ruby/
|
8
|
+
require 'chalk_ruby/http/http_requester_chalk'
|
10
9
|
require 'chalk_ruby/client'
|
11
10
|
require 'chalk_ruby/error'
|
12
11
|
require 'chalk_ruby/logger_helper'
|
data/sig/chalk_ruby/client.rbs
CHANGED
@@ -2,7 +2,7 @@ module ChalkRuby
|
|
2
2
|
class Client
|
3
3
|
@config: Config
|
4
4
|
@token: Token?
|
5
|
-
@transporter:
|
5
|
+
@transporter: Http::HttpRequesterChalk
|
6
6
|
|
7
7
|
def self.create: -> Client
|
8
8
|
|
@@ -11,15 +11,24 @@ module ChalkRuby
|
|
11
11
|
def get_token: -> Token
|
12
12
|
|
13
13
|
def query: (
|
14
|
-
|
14
|
+
Hash[Symbol | String, untyped] input,
|
15
15
|
[String] output,
|
16
|
-
Time
|
17
|
-
|
16
|
+
now: Time?,
|
17
|
+
staleness: Hash[String, String],
|
18
|
+
tags: [String]?,
|
19
|
+
branch: String?,
|
20
|
+
correlation_id: String?,
|
21
|
+
query_name: String?,
|
22
|
+
meta: Hash[String, String]?,
|
23
|
+
explain: bool,
|
24
|
+
include_meta: bool,
|
25
|
+
store_plan_stages: bool
|
18
26
|
) -> Hash[Symbol, untyped]
|
19
27
|
|
20
28
|
private
|
21
29
|
|
22
30
|
def get_authenticated_headers: -> Hash[Symbol, String | nil]
|
31
|
+
|
23
32
|
def get_unauthenticated_headers: -> Hash[Symbol, String | nil]
|
24
33
|
|
25
34
|
def query_server_host: -> String
|
@@ -14,15 +14,15 @@ module ChalkRuby
|
|
14
14
|
attr_accessor connect_timeout: Integer
|
15
15
|
|
16
16
|
type options = {
|
17
|
-
client_id: String
|
18
|
-
client_secret: String
|
19
|
-
environment: String
|
20
|
-
api_server: String
|
21
|
-
query_server: String
|
22
|
-
query_timeout: Integer
|
23
|
-
api_timeout: Integer
|
24
|
-
connect_timeout: Integer
|
25
|
-
compression_type: String
|
17
|
+
client_id: String?,
|
18
|
+
client_secret: String?,
|
19
|
+
environment: String?,
|
20
|
+
api_server: String?,
|
21
|
+
query_server: String?,
|
22
|
+
query_timeout: Integer?,
|
23
|
+
api_timeout: Integer?,
|
24
|
+
connect_timeout: Integer?,
|
25
|
+
compression_type: String?
|
26
26
|
}
|
27
27
|
|
28
28
|
def initialize: (options opts) -> void
|
data/sig/chalk_ruby/defaults.rbs
CHANGED
@@ -3,9 +3,8 @@ require 'rspec/autorun'
|
|
3
3
|
require 'chalk_ruby/client'
|
4
4
|
require 'chalk_ruby/error'
|
5
5
|
|
6
|
-
CLIENT_ID = '
|
7
|
-
CLIENT_SECRET = '
|
8
|
-
|
6
|
+
CLIENT_ID = ''
|
7
|
+
CLIENT_SECRET = ''
|
9
8
|
|
10
9
|
RSpec.describe 'Online query' do
|
11
10
|
it 'should accept valid queries' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chalk_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chalk AI, Inc.
|
@@ -214,26 +214,27 @@ files:
|
|
214
214
|
- chalk_ruby.gemspec
|
215
215
|
- lib/chalk_ruby.rb
|
216
216
|
- lib/chalk_ruby/client.rb
|
217
|
-
- lib/chalk_ruby/config
|
217
|
+
- lib/chalk_ruby/config.rb
|
218
218
|
- lib/chalk_ruby/defaults.rb
|
219
219
|
- lib/chalk_ruby/error.rb
|
220
220
|
- lib/chalk_ruby/helpers.rb
|
221
221
|
- lib/chalk_ruby/http/http_requester.rb
|
222
|
+
- lib/chalk_ruby/http/http_requester_chalk.rb
|
222
223
|
- lib/chalk_ruby/http/response.rb
|
223
224
|
- lib/chalk_ruby/logger_helper.rb
|
224
|
-
- lib/chalk_ruby/
|
225
|
+
- lib/chalk_ruby/token.rb
|
225
226
|
- lib/chalk_ruby/version.rb
|
226
227
|
- renovate.json
|
227
228
|
- sig/chalk_ruby/client.rbs
|
228
|
-
- sig/chalk_ruby/config
|
229
|
+
- sig/chalk_ruby/config.rbs
|
229
230
|
- sig/chalk_ruby/defaults.rbs
|
230
231
|
- sig/chalk_ruby/error.rbs
|
231
232
|
- sig/chalk_ruby/helpers.rbs
|
233
|
+
- sig/chalk_ruby/http/_connection.rbs
|
232
234
|
- sig/chalk_ruby/http/http_requester.rbs
|
235
|
+
- sig/chalk_ruby/http/http_requester_chalk.rbs
|
233
236
|
- sig/chalk_ruby/http/response.rbs
|
234
|
-
- sig/chalk_ruby/interfaces/_connection.rbs
|
235
237
|
- sig/chalk_ruby/token.rbs
|
236
|
-
- sig/chalk_ruby/transport/transport.rbs
|
237
238
|
- sig/chalk_ruby/versions.rbs
|
238
239
|
- test/chalk_ai/integration/client_test.rb
|
239
240
|
- test/chalk_ai/test_helper.rb
|
File without changes
|