Class: Celerb::AsyncResult
- Inherits:
-
Object
- Object
- Celerb::AsyncResult
- Defined in:
- lib/celerb/task.rb
Instance Attribute Summary collapse
-
#task_id ⇒ Object
readonly
Returns the value of attribute task_id.
Instance Method Summary collapse
-
#initialize(task_id) ⇒ AsyncResult
constructor
A new instance of AsyncResult.
-
#wait(expiration, &blk) ⇒ Object
Awaits a task result and calls block when the result is available.
Constructor Details
#initialize(task_id) ⇒ AsyncResult
Returns a new instance of AsyncResult.
43 44 45 |
# File 'lib/celerb/task.rb', line 43 def initialize(task_id) @task_id = task_id end |
Instance Attribute Details
#task_id ⇒ Object (readonly)
Returns the value of attribute task_id.
41 42 43 |
# File 'lib/celerb/task.rb', line 41 def task_id @task_id end |
Instance Method Details
#wait(expiration, &blk) ⇒ Object
Awaits a task result and calls block when the result is available. Expiration needs to be explicitly specified in seconds to prevent memory leaks. Result handlers are periodically checked and expired ones are deleted.
50 51 52 |
# File 'lib/celerb/task.rb', line 50 def wait(expiration, &blk) TaskPublisher.register_result_handler(@task_id, expiration, &blk) end |