keen 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -2
- data/lib/keen.rb +2 -1
- data/lib/keen/client.rb +3 -1
- data/lib/keen/client/maintenance_methods.rb +1 -1
- data/lib/keen/client/publishing_methods.rb +1 -1
- data/lib/keen/client/querying_methods.rb +2 -2
- data/lib/keen/client/saved_queries.rb +3 -3
- data/lib/keen/http.rb +2 -1
- data/lib/keen/version.rb +1 -1
- data/spec/keen/client_spec.rb +5 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e480ce2b302b1c4176b0d7af6860fdcadab0d18c
|
4
|
+
data.tar.gz: 9e6563894e8ca2c84e6e1812e251d3ad4c792bcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be393227858df11b2ef2f8a1b87326747e13285d318d9fc627ebd8449e816ec80788a19ca70c576599b6be201cfddb45617572d773dc2fa2c7da4b92d8f1ea26
|
7
|
+
data.tar.gz: 33fa125a869b6969587a0f5e32c0e09b665f98b1f8e3ea7342c3d1d11e1f7ce3c5361edd8e2db5a919060325e8464e0c727bceac74348b492eb8e27d30613380
|
data/README.md
CHANGED
@@ -375,12 +375,19 @@ You can use the scoped key created in Ruby for API requests from any client. Sco
|
|
375
375
|
|
376
376
|
##### HTTP Read Timeout
|
377
377
|
|
378
|
-
The default `Net
|
378
|
+
The default `Net::HTTP` timeout is 60 seconds. That's usually enough, but if you're querying over a large collection you may need to increase it. The timeout on the API side is 300 seconds, so that's as far as you'd want to go. You can configure a read timeout (in seconds) by setting a `KEEN_READ_TIMEOUT` environment variable, or by passing in a `read_timeout` option to the client constructor as follows:
|
379
379
|
|
380
380
|
``` ruby
|
381
381
|
keen = Keen::Client.new(:read_timeout => 300)
|
382
382
|
```
|
383
383
|
|
384
|
+
You can also configure the `NET::HTTP` open timeout, default is 60 seconds. To configure the timeout (in seconds) either set `KEEN_OPEN_TIMEOUT` environment variable, or by passing in a `open_timeout` option to the client constructor as follows:
|
385
|
+
|
386
|
+
``` ruby
|
387
|
+
keen = Keen::Client.new(:open_timeout => 30)
|
388
|
+
```
|
389
|
+
|
390
|
+
|
384
391
|
##### HTTP Proxy
|
385
392
|
|
386
393
|
You can set the `KEEN_PROXY_TYPE` and `KEEN_PROXY_URL` environment variables to enable HTTP proxying. `KEEN_PROXY_TYPE` should be set to `socks5`. You can also configure this on client instances by passing in `proxy_type` and `proxy_url` keys.
|
@@ -412,6 +419,9 @@ If you want some bot protection, check out the [Voight-Kampff](https://github.co
|
|
412
419
|
|
413
420
|
### Changelog
|
414
421
|
|
422
|
+
##### 0.9.10
|
423
|
+
+ Add ability to set the `open_time` setting for the http client.
|
424
|
+
|
415
425
|
##### 0.9.9
|
416
426
|
+ Added the ability to send additional optional headers.
|
417
427
|
|
@@ -419,7 +429,7 @@ If you want some bot protection, check out the [Voight-Kampff](https://github.co
|
|
419
429
|
+ Added a new header `Keen-Sdk` that sends the SDK version information on all requests.
|
420
430
|
|
421
431
|
##### 0.9.6
|
422
|
-
+ Updated behavior of saved queries to allow fetching results using the READ KEY as opposed to requiring the MASTER KEY, making the gem consistent with https://keen.io/docs/api/#getting-saved-query-results
|
432
|
+
+ Updated behavior of saved queries to allow fetching results using the READ KEY as opposed to requiring the MASTER KEY, making the gem consistent with https://keen.io/docs/api/#getting-saved-query-results
|
423
433
|
|
424
434
|
##### 0.9.5
|
425
435
|
+ Fix bug with scoped key generation not working with newer Keen projects.
|
data/lib/keen.rb
CHANGED
@@ -75,7 +75,8 @@ module Keen
|
|
75
75
|
:api_url => ENV['KEEN_API_URL'],
|
76
76
|
:proxy_url => ENV['KEEN_PROXY_URL'],
|
77
77
|
:proxy_type => ENV['KEEN_PROXY_TYPE'],
|
78
|
-
:read_timeout => ENV['KEEN_READ_TIMEOUT']
|
78
|
+
:read_timeout => ENV['KEEN_READ_TIMEOUT'],
|
79
|
+
:open_timeout => ENV['KEEN_OPEN_TIMEOUT']
|
79
80
|
)
|
80
81
|
end
|
81
82
|
end
|
data/lib/keen/client.rb
CHANGED
@@ -17,7 +17,7 @@ module Keen
|
|
17
17
|
include Keen::Client::QueryingMethods
|
18
18
|
include Keen::Client::MaintenanceMethods
|
19
19
|
|
20
|
-
attr_accessor :project_id, :write_key, :read_key, :master_key, :api_url, :proxy_url, :proxy_type, :read_timeout
|
20
|
+
attr_accessor :project_id, :write_key, :read_key, :master_key, :api_url, :proxy_url, :proxy_type, :read_timeout, :open_timeout
|
21
21
|
|
22
22
|
CONFIG = {
|
23
23
|
:api_url => "https://api.keen.io",
|
@@ -54,6 +54,8 @@ module Keen
|
|
54
54
|
self.proxy_url, self.proxy_type = options.values_at(:proxy_url, :proxy_type)
|
55
55
|
|
56
56
|
self.read_timeout = options[:read_timeout].to_f unless options[:read_timeout].nil?
|
57
|
+
|
58
|
+
self.open_timeout = options[:open_timeout].to_f unless options[:open_timeout].nil?
|
57
59
|
end
|
58
60
|
|
59
61
|
def saved_queries
|
@@ -161,7 +161,7 @@ module Keen
|
|
161
161
|
def publish_body(path, body, error_method)
|
162
162
|
begin
|
163
163
|
response = Keen::HTTP::Sync.new(
|
164
|
-
self.api_url, self.proxy_url, self.read_timeout).post(
|
164
|
+
self.api_url, self.proxy_url, self.read_timeout, self.open_timeout).post(
|
165
165
|
:path => path,
|
166
166
|
:headers => api_headers(self.write_key, "sync"),
|
167
167
|
:body => body)
|
@@ -242,7 +242,7 @@ module Keen
|
|
242
242
|
|
243
243
|
query_params = params.dup
|
244
244
|
query_params[:event_collection] = event_collection.to_s if event_collection
|
245
|
-
Keen::HTTP::Sync.new(self.api_url, self.proxy_url, self.read_timeout).post(
|
245
|
+
Keen::HTTP::Sync.new(self.api_url, self.proxy_url, self.read_timeout, self.open_timeout).post(
|
246
246
|
:path => api_query_resource_path(analysis_type),
|
247
247
|
:headers => request_headers(options),
|
248
248
|
:body => MultiJson.encode(query_params)
|
@@ -262,7 +262,7 @@ module Keen
|
|
262
262
|
|
263
263
|
def get_response(url, options={})
|
264
264
|
uri = URI.parse(url)
|
265
|
-
Keen::HTTP::Sync.new(self.api_url, self.proxy_url, self.read_timeout).get(
|
265
|
+
Keen::HTTP::Sync.new(self.api_url, self.proxy_url, self.read_timeout, self.open_timeout).get(
|
266
266
|
:path => "#{uri.path}?#{uri.query}",
|
267
267
|
:headers => request_headers(options)
|
268
268
|
)
|
@@ -25,7 +25,7 @@ class SavedQueries
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def create(saved_query_name, saved_query_body)
|
28
|
-
response = Keen::HTTP::Sync.new(client.api_url, client.proxy_url, client.read_timeout).put(
|
28
|
+
response = Keen::HTTP::Sync.new(client.api_url, client.proxy_url, client.read_timeout, client.open_timeout).put(
|
29
29
|
path: "#{saved_query_base_url}/#{saved_query_name}",
|
30
30
|
headers: api_headers(client.master_key, "sync"),
|
31
31
|
body: saved_query_body
|
@@ -35,7 +35,7 @@ class SavedQueries
|
|
35
35
|
alias_method :update, :create
|
36
36
|
|
37
37
|
def delete(saved_query_name)
|
38
|
-
response = Keen::HTTP::Sync.new(client.api_url, client.proxy_url, client.read_timeout).delete(
|
38
|
+
response = Keen::HTTP::Sync.new(client.api_url, client.proxy_url, client.read_timeout, client.open_timeout).delete(
|
39
39
|
path: "#{saved_query_base_url}/#{saved_query_name}",
|
40
40
|
headers: api_headers(client.master_key, "sync")
|
41
41
|
)
|
@@ -47,7 +47,7 @@ class SavedQueries
|
|
47
47
|
attr_reader :client
|
48
48
|
|
49
49
|
def saved_query_response(api_key, path = "")
|
50
|
-
Keen::HTTP::Sync.new(client.api_url, client.proxy_url, client.read_timeout).get(
|
50
|
+
Keen::HTTP::Sync.new(client.api_url, client.proxy_url, client.read_timeout, client.open_timeout).get(
|
51
51
|
path: saved_query_base_url + path,
|
52
52
|
headers: api_headers(api_key, "sync")
|
53
53
|
)
|
data/lib/keen/http.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Keen
|
2
2
|
module HTTP
|
3
3
|
class Sync
|
4
|
-
def initialize(base_url, proxy_url=nil, read_timeout=nil)
|
4
|
+
def initialize(base_url, proxy_url=nil, read_timeout=nil, open_timeout=nil)
|
5
5
|
require 'uri'
|
6
6
|
require 'net/http'
|
7
7
|
|
@@ -10,6 +10,7 @@ module Keen
|
|
10
10
|
arguments+= proxy_arguments_for(proxy_url) if proxy_url
|
11
11
|
|
12
12
|
@http = Net::HTTP.new(*arguments)
|
13
|
+
@http.open_timeout = open_timeout if open_timeout
|
13
14
|
@http.read_timeout = read_timeout if read_timeout
|
14
15
|
|
15
16
|
if uri.scheme == "https"
|
data/lib/keen/version.rb
CHANGED
data/spec/keen/client_spec.rb
CHANGED
@@ -7,6 +7,7 @@ describe Keen::Client do
|
|
7
7
|
let(:api_url) { "http://fake.keen.io:fakeport" }
|
8
8
|
let(:client) { Keen::Client.new(:project_id => project_id) }
|
9
9
|
let(:read_timeout) { 40 }
|
10
|
+
let(:open_timeout) { 10 }
|
10
11
|
|
11
12
|
before do
|
12
13
|
ENV["KEEN_PROJECT_ID"] = nil
|
@@ -14,6 +15,7 @@ describe Keen::Client do
|
|
14
15
|
ENV["KEEN_READ_KEY"] = nil
|
15
16
|
ENV["KEEN_API_URL"] = nil
|
16
17
|
ENV["KEEN_READ_TIMEOUT"] = nil
|
18
|
+
ENV["KEEN_OPEN_TIMEOUT"] = nil
|
17
19
|
end
|
18
20
|
|
19
21
|
describe "#initialize" do
|
@@ -32,12 +34,14 @@ describe Keen::Client do
|
|
32
34
|
:write_key => write_key,
|
33
35
|
:read_key => read_key,
|
34
36
|
:api_url => api_url,
|
35
|
-
:read_timeout => read_timeout
|
37
|
+
:read_timeout => read_timeout,
|
38
|
+
:open_timeout => open_timeout)
|
36
39
|
expect(client.write_key).to eq(write_key)
|
37
40
|
expect(client.read_key).to eq(read_key)
|
38
41
|
expect(client.project_id).to eq(project_id)
|
39
42
|
expect(client.api_url).to eq(api_url)
|
40
43
|
expect(client.read_timeout).to eq(read_timeout)
|
44
|
+
expect(client.open_timeout).to eq(open_timeout)
|
41
45
|
end
|
42
46
|
|
43
47
|
it "should set a default api_url" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Kleissner
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-05-
|
12
|
+
date: 2017-05-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|