kt 0.3.1 → 0.4.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/kt.rb +19 -3
  3. data/lib/kt/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c957f1c88aa3b32505c9b403f12a7c3285d1e83c
4
- data.tar.gz: 7fcdb8d8afc62ad39f41111a8973a9f900b91220
3
+ metadata.gz: 45b09ad2578972548e2fadd526f9856d55754905
4
+ data.tar.gz: 0c7b538388ae55d883cba2eb80889c1aef01720c
5
5
  SHA512:
6
- metadata.gz: 87ec5f5630f5057f938bcdeaa0c5e3c5fc271332010fcc61e35c4ae65dba71f048eeea13677db23e59c6955d35b9c686e775bfa3cc29b36f43a69f68f60db603
7
- data.tar.gz: 2f66c19d17ae676c0e25bbf0b0f88c977b8da92e7dcb8530624d0788e5457417c7d1062cafa966d0cbc0d351f6111e210aacc3e734bcfb668cef5eb2f76ad245
6
+ metadata.gz: 0d89d45cb24e2af5d012600ff3b208ba6eb0d51e2fd23da06683472ed4782cf3e1c436004c3ab7ab76172838922a1ee42a4103cae917547a96a2133a4317c6e6
7
+ data.tar.gz: e480e19ee797e6fa33c2f8d16ae4c19a3a6270778d19eea32dbff32030f2ec3c4a3e16e99f0cc7830719b5804a20aa7ec860777f9e26c1878b2acabae2bc6d3f
data/lib/kt.rb CHANGED
@@ -18,9 +18,12 @@ class KT
18
18
  @port = options.fetch(:port, 1978)
19
19
  @poolsize = options.fetch(:poolsize, 5)
20
20
  @timeout = options.fetch(:timeout, 5.0)
21
+ @connect_timeout = options.fetch(:connect_timeout, 0.5)
22
+ @read_timeout = options.fetch(:read_timeout, 0.5)
23
+ @write_timeout = options.fetch(:write_timeout, 0.5)
21
24
 
22
25
  @pool = ConnectionPool.new(size: @poolsize, timeout: @timeout) do
23
- Excon.new("http://#{@host}:#{@port}")
26
+ Excon.new("http://#{@host}:#{@port}", :connect_timeout => @connect_timeout)
24
27
  end
25
28
  end
26
29
 
@@ -312,7 +315,13 @@ class KT
312
315
  headers = {"Content-Type" => encoding}
313
316
 
314
317
  @pool.with do |conn|
315
- res = conn.post(:path => path, :headers => headers, :body => body)
318
+ res = conn.post(
319
+ :path => path,
320
+ :headers => headers,
321
+ :body => body,
322
+ :read_timeout => @read_timeout,
323
+ :write_timeout => @write_timeout,
324
+ )
316
325
  # return res.status_code, decode_values(res.body, res.headers.get("Content-Type").join("; "))
317
326
  return res.status, decode_values(res.body, res.headers["Content-Type"])
318
327
  end
@@ -320,7 +329,14 @@ class KT
320
329
 
321
330
  def do_rest(method, key, value="")
322
331
  @pool.with do |conn|
323
- res = conn.request(:method => method, :path => url_encode(key), :headers => EMPTY_HEADERS, :body => value)
332
+ res = conn.request(
333
+ :method => method,
334
+ :path => url_encode(key),
335
+ :headers => EMPTY_HEADERS,
336
+ :body => value,
337
+ :read_timeout => @read_timeout,
338
+ :write_timeout => @write_timeout,
339
+ )
324
340
  return res.status, res.body
325
341
  end
326
342
  end
@@ -1,3 +1,3 @@
1
1
  class KT
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Teodor Pripoae
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-28 00:00:00.000000000 Z
11
+ date: 2016-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon