Class: Server
- Inherits:
-
Object
- Object
- Server
- Defined in:
- lib/thrift_client/server.rb
Instance Method Summary collapse
- #active? ⇒ Boolean
- #destroy ⇒ Object
-
#initialize(connect_string, options = {}) ⇒ Server
constructor
A new instance of Server.
- #to_s ⇒ Object
- #with ⇒ Object
Constructor Details
#initialize(connect_string, options = {}) ⇒ Server
Returns a new instance of Server.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/thrift_client/server.rb', line 3 def initialize(connect_string, = {}) @active = false @host, @port = parse_connect_string(connect_string) @options = pool_class = nil if @options[:transport] == Thrift::EventMachineTransport require "thrift_client/pool/fiber_connection_pool" pool_class = FiberConnectionPool else require "thrift_client/pool/thread_connection_pool" pool_class = ThreadConnectionPool end @connection_pool = pool_class.new(:size => @options[:size]){ create_client } @active = true end |
Instance Method Details
#active? ⇒ Boolean
21 22 23 |
# File 'lib/thrift_client/server.rb', line 21 def active? @active end |
#destroy ⇒ Object
25 26 27 28 |
# File 'lib/thrift_client/server.rb', line 25 def destroy @active = false @connection_pool.destroy end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/thrift_client/server.rb', line 39 def to_s "#{@host}:#{@port}" end |
#with ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/thrift_client/server.rb', line 30 def with @connection_pool.execute { | connection | if connection == nil puts "fetal error, connection is nil" end yield connection } end |