waterfall-client-rb 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 644c94c70dc8120926899ff86d8123af0db196db
4
- data.tar.gz: 7c9898ed75d5c8310b9b300087e434af89bd7249
3
+ metadata.gz: 74844ef19dc3422fdd945d0306aea818a298e30e
4
+ data.tar.gz: 74ff9c7a83fd5800ab0e57983c723b639186783f
5
5
  SHA512:
6
- metadata.gz: 9e78b24d79f003e80279d8fbe5c0fe25d13773dbcc852b6832ffd7e93baec258128ce953419fa660fa64df420e3da905bfc025aba9038fc873bb625a4a45c4df
7
- data.tar.gz: 1ceb7aac213f6b98f2f6d270410886533fcd928f143976323616ffb55e66a348a96e2a7cf5a4b2abe79ff6a034a3f7200739108322afc1afc73d4d073a9f40c5
6
+ metadata.gz: 57183436c0ae39a9f25cafd0ad95f824bbd4747d0fe0e5cea2fbd4987b79c15f23efa095889fb36e195d3fd4a3d3433952ba0e07cc877fcf481c495f9a2b5b7d
7
+ data.tar.gz: 858aa941af39d12940055b624a23da09ca159211377e797a1fa9088a74b467d955a1d812c3e282a0a67888685a19f808f9d1d8a47b454f44b039041f6becc820
@@ -1,24 +1,40 @@
1
1
  require 'waterfall/version'
2
2
  require 'waterfall/client/thrift/waterfall_service'
3
+ require 'connection_pool'
3
4
 
4
5
  module Waterfall
5
6
  class Client
6
7
  def initialize(options = {})
7
8
  settings = {host: 'localhost', port: 5290}.merge(options)
8
-
9
- @transport = ::Thrift::FramedTransport.new(::Thrift::Socket.new(settings[:host], settings[:port]))
10
- protocol = ::Thrift::BinaryProtocol.new(@transport)
11
- @client = Thrift::WaterfallService::Client.new(protocol)
12
-
13
- @transport.open
9
+ @pool = ConnectionPool.new { ClientWrapper.new(settings) }
14
10
  end
15
11
 
16
12
  def next_id
17
- @client.nextId
13
+ @pool.with do |client|
14
+ client.next_id
15
+ end
18
16
  end
19
17
 
18
+
20
19
  def close
21
- @transport.close
20
+ @pool.shutdown { |client| client.close }
21
+ end
22
+
23
+ class ClientWrapper
24
+ def initialize(options)
25
+ @transport = ::Thrift::FramedTransport.new(::Thrift::Socket.new(options[:host], options[:port]))
26
+ protocol = ::Thrift::BinaryProtocol.new(@transport)
27
+ @client = Thrift::WaterfallService::Client.new(protocol)
28
+ @transport.open
29
+ end
30
+
31
+ def next_id
32
+ @client.nextId
33
+ end
34
+
35
+ def close
36
+ @transport.close
37
+ end
22
38
  end
23
39
  end
24
40
  end
@@ -1,4 +1,4 @@
1
1
  module Waterfall
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
4
4
 
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency 'bundler', '~> 1.9'
22
22
  spec.add_development_dependency 'rake', '~> 10.0'
23
23
  spec.add_runtime_dependency 'thrift', '0.8.0'
24
+ spec.add_runtime_dependency 'connection_pool', '2.2.0'
24
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: waterfall-client-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Herrmann
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.8.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: connection_pool
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 2.2.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 2.2.0
55
69
  description:
56
70
  email:
57
71
  - sven.herrmann@thatscalaguy.de
@@ -70,7 +84,6 @@ files:
70
84
  - lib/waterfall/client/thrift/waterfall_types.rb
71
85
  - lib/waterfall/version.rb
72
86
  - waterfall-client-rb.gemspec
73
- - waterfall-client-rb.iml
74
87
  homepage: https://github.com/ThatScalaGuy/waterfall-client-rb
75
88
  licenses:
76
89
  - MIT