Class: Restate::DurableCallFuture
- Inherits:
-
DurableFuture
- Object
- DurableFuture
- Restate::DurableCallFuture
- Defined in:
- lib/restate/durable_future.rb
Overview
A durable future for service/object/workflow calls. Adds invocation_id and cancel on top of DurableFuture. Returned by ctx.service_call, ctx.object_call, ctx.workflow_call.
Instance Attribute Summary
Attributes inherited from DurableFuture
Instance Method Summary collapse
-
#await ⇒ Object
Block until the result is available and return it.
-
#cancel ⇒ Object
Cancel the remote invocation.
-
#initialize(ctx, result_handle, invocation_id_handle, output_serde:) ⇒ DurableCallFuture
constructor
A new instance of DurableCallFuture.
-
#invocation_id ⇒ String
Returns the invocation ID of the remote call.
Methods inherited from DurableFuture
Constructor Details
#initialize(ctx, result_handle, invocation_id_handle, output_serde:) ⇒ DurableCallFuture
Returns a new instance of DurableCallFuture.
42 43 44 45 46 47 48 |
# File 'lib/restate/durable_future.rb', line 42 def initialize(ctx, result_handle, invocation_id_handle, output_serde:) super(ctx, result_handle) @invocation_id_handle = invocation_id_handle @output_serde = output_serde @invocation_id_resolved = false @invocation_id_value = nil end |
Instance Method Details
#await ⇒ Object
Block until the result is available and return it. Deserializes via output_serde.
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/restate/durable_future.rb', line 51 def await unless @resolved raw = @ctx.resolve_handle(@handle) @value = if raw.nil? || @output_serde.nil? raw else @output_serde.deserialize(raw) end @resolved = true end @value end |
#cancel ⇒ Object
Cancel the remote invocation.
76 77 78 |
# File 'lib/restate/durable_future.rb', line 76 def cancel @ctx.cancel_invocation(invocation_id) end |
#invocation_id ⇒ String
Returns the invocation ID of the remote call. Lazily resolved.
67 68 69 70 71 72 73 |
# File 'lib/restate/durable_future.rb', line 67 def invocation_id unless @invocation_id_resolved @invocation_id_value = @ctx.resolve_handle(@invocation_id_handle) @invocation_id_resolved = true end @invocation_id_value end |