Class: FileRpc::Client
- Inherits:
-
Object
- Object
- FileRpc::Client
- Defined in:
- lib/file_rpc/client.rb
Instance Attribute Summary collapse
-
#poll_interval ⇒ Object
readonly
Returns the value of attribute poll_interval.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
Instance Method Summary collapse
- #execute(args:, override_timeout: nil) ⇒ Object
-
#initialize(queue_name:, transport_class: Transport::FileSystem) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(queue_name:, transport_class: Transport::FileSystem) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 |
# File 'lib/file_rpc/client.rb', line 7 def initialize(queue_name:, transport_class: Transport::FileSystem) @transport = transport_class.new(queue_name: queue_name) @timeout = FileRpc.configuration.default_timeout @poll_interval = FileRpc.configuration.poll_interval end |
Instance Attribute Details
#poll_interval ⇒ Object (readonly)
Returns the value of attribute poll_interval.
5 6 7 |
# File 'lib/file_rpc/client.rb', line 5 def poll_interval @poll_interval end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/file_rpc/client.rb', line 5 def timeout @timeout end |
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
5 6 7 |
# File 'lib/file_rpc/client.rb', line 5 def transport @transport end |
Instance Method Details
#execute(args:, override_timeout: nil) ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/file_rpc/client.rb', line 13 def execute(args:, override_timeout: nil) execution_timeout = override_timeout || timeout request = Message::Request.new(args: args, timeout: execution_timeout) transport.write_request(request) poll_for_response(request.id, execution_timeout) ensure transport.cleanup(request.id) if request end |