Class: Thrifter::Client::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/thrifter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app, transport, client, config) ⇒ Dispatcher

Returns a new instance of Dispatcher.



90
91
92
# File 'lib/thrifter.rb', line 90

def initialize(app, transport, client, config)
  @app, @transport, @client, @config = app, transport, client, config
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



88
89
90
# File 'lib/thrifter.rb', line 88

def app
  @app
end

#clientObject (readonly)

Returns the value of attribute client.



88
89
90
# File 'lib/thrifter.rb', line 88

def client
  @client
end

#configObject (readonly)

Returns the value of attribute config.



88
89
90
# File 'lib/thrifter.rb', line 88

def config
  @config
end

#transportObject (readonly)

Returns the value of attribute transport.



88
89
90
# File 'lib/thrifter.rb', line 88

def transport
  @transport
end

Instance Method Details

#call(rpc) ⇒ Object



94
95
96
97
98
99
100
101
102
103
# File 'lib/thrifter.rb', line 94

def call(rpc)
  transport.open unless transport.open?

  client.send(rpc.name, *rpc.args).tap do
    transport.close unless config.keep_alive
  end
rescue => ex
  transport.close
  raise ex
end