Class: Restate::Server::ScopedContext
- Inherits:
-
Object
- Object
- Restate::Server::ScopedContext
- Defined in:
- lib/restate/server/context.rb,
sig/restate.rbs
Overview
A context for making RPC calls within a specific scope.
NOTE: This API is in preview and is not enabled by default. See Context#scope for how to enable it and for the full semantics.
Returned by ctx.scope(scope): calls and sends made through this context
carry the captured scope, and each method additionally accepts an optional
limit_key.
The limit key enforces hierarchical concurrency limits on invocations sharing
the same scope. It can have one or two levels separated by / (e.g. "tenant1"
or "tenant1/user42"). Each level must consist only of [a-zA-Z0-9_.-]
characters, 1 <= length <= 36.
The limit key is not part of the request identity: two calls to the same target with the same scope and object key but different limit keys refer to the same resource instance. The limit key only affects concurrency limits.
Instance Method Summary collapse
-
#initialize(ctx, scope) ⇒ ScopedContext
constructor
A new instance of ScopedContext.
-
#object_call(service, handler, key, arg, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET, output_serde: NOT_SET) ⇒ DurableCallFuture
Durably calls a handler on a Restate virtual object, within this scope.
-
#object_send(service, handler, key, arg, delay: nil, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET) ⇒ SendHandle
Fire-and-forget send to a Restate virtual object handler, within this scope.
-
#service_call(service, handler, arg, key: nil, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET, output_serde: NOT_SET) ⇒ DurableCallFuture
Durably calls a handler on a Restate service, within this scope.
-
#service_send(service, handler, arg, key: nil, delay: nil, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET) ⇒ SendHandle
Fire-and-forget send to a Restate service handler, within this scope.
-
#workflow_call(service, handler, key, arg, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET, output_serde: NOT_SET) ⇒ DurableCallFuture
Durably calls a handler on a Restate workflow, within this scope.
-
#workflow_send(service, handler, key, arg, delay: nil, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET) ⇒ SendHandle
Fire-and-forget send to a Restate workflow handler, within this scope.
Constructor Details
#initialize(ctx, scope) ⇒ ScopedContext
Returns a new instance of ScopedContext.
806 807 808 809 |
# File 'lib/restate/server/context.rb', line 806 def initialize(ctx, scope) @ctx = ctx @scope = scope end |
Instance Method Details
#object_call(service, handler, key, arg, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET, output_serde: NOT_SET) ⇒ DurableCallFuture
Durably calls a handler on a Restate virtual object, within this scope.
833 834 835 836 837 838 839 840 841 |
# File 'lib/restate/server/context.rb', line 833 def object_call(service, handler, key, arg, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET, output_serde: NOT_SET) @ctx.object_call( service, handler, key, arg, idempotency_key: idempotency_key, headers: headers, input_serde: input_serde, output_serde: output_serde, scope: @scope, limit_key: limit_key ) end |
#object_send(service, handler, key, arg, delay: nil, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET) ⇒ SendHandle
Fire-and-forget send to a Restate virtual object handler, within this scope.
844 845 846 847 848 849 850 851 |
# File 'lib/restate/server/context.rb', line 844 def object_send(service, handler, key, arg, delay: nil, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET) @ctx.object_send( service, handler, key, arg, delay: delay, idempotency_key: idempotency_key, headers: headers, input_serde: input_serde, scope: @scope, limit_key: limit_key ) end |
#service_call(service, handler, arg, key: nil, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET, output_serde: NOT_SET) ⇒ DurableCallFuture
Durably calls a handler on a Restate service, within this scope.
812 813 814 815 816 817 818 819 820 |
# File 'lib/restate/server/context.rb', line 812 def service_call(service, handler, arg, key: nil, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET, output_serde: NOT_SET) @ctx.service_call( service, handler, arg, key: key, idempotency_key: idempotency_key, headers: headers, input_serde: input_serde, output_serde: output_serde, scope: @scope, limit_key: limit_key ) end |
#service_send(service, handler, arg, key: nil, delay: nil, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET) ⇒ SendHandle
Fire-and-forget send to a Restate service handler, within this scope.
823 824 825 826 827 828 829 830 |
# File 'lib/restate/server/context.rb', line 823 def service_send(service, handler, arg, key: nil, delay: nil, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET) @ctx.service_send( service, handler, arg, key: key, delay: delay, idempotency_key: idempotency_key, headers: headers, input_serde: input_serde, scope: @scope, limit_key: limit_key ) end |
#workflow_call(service, handler, key, arg, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET, output_serde: NOT_SET) ⇒ DurableCallFuture
Durably calls a handler on a Restate workflow, within this scope.
854 855 856 857 858 859 860 861 862 |
# File 'lib/restate/server/context.rb', line 854 def workflow_call(service, handler, key, arg, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET, output_serde: NOT_SET) @ctx.workflow_call( service, handler, key, arg, idempotency_key: idempotency_key, headers: headers, input_serde: input_serde, output_serde: output_serde, scope: @scope, limit_key: limit_key ) end |
#workflow_send(service, handler, key, arg, delay: nil, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET) ⇒ SendHandle
Fire-and-forget send to a Restate workflow handler, within this scope.
865 866 867 868 869 870 871 872 |
# File 'lib/restate/server/context.rb', line 865 def workflow_send(service, handler, key, arg, delay: nil, limit_key: nil, idempotency_key: nil, headers: nil, input_serde: NOT_SET) @ctx.workflow_send( service, handler, key, arg, delay: delay, idempotency_key: idempotency_key, headers: headers, input_serde: input_serde, scope: @scope, limit_key: limit_key ) end |