restate-sdk 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +512 -9
- data/ext/restate_internal/Cargo.toml +2 -2
- data/ext/restate_internal/src/lib.rs +54 -8
- data/lib/restate/context.rb +37 -3
- data/lib/restate/server/context.rb +154 -20
- data/lib/restate/service.rb +10 -4
- data/lib/restate/service_proxy.rb +16 -2
- data/lib/restate/version.rb +1 -1
- data/lib/restate/virtual_object.rb +10 -4
- data/lib/restate/vm.rb +15 -8
- data/lib/restate/workflow.rb +14 -4
- data/lib/restate.rb +17 -5
- data/sig/restate.rbs +15 -4
- metadata +2 -2
data/lib/restate/vm.rb
CHANGED
|
@@ -18,7 +18,8 @@ end
|
|
|
18
18
|
|
|
19
19
|
module Restate
|
|
20
20
|
# Ruby-side data types for VM results
|
|
21
|
-
Invocation = Struct.new(:invocation_id, :random_seed, :headers, :input_buffer, :key,
|
|
21
|
+
Invocation = Struct.new(:invocation_id, :random_seed, :headers, :input_buffer, :key,
|
|
22
|
+
:scope, :limit_key, :idempotency_key, keyword_init: true)
|
|
22
23
|
Failure = Struct.new(:code, :message, :stacktrace, :metadata, keyword_init: true)
|
|
23
24
|
|
|
24
25
|
class NotReady; end
|
|
@@ -116,7 +117,10 @@ module Restate
|
|
|
116
117
|
random_seed: inp.random_seed,
|
|
117
118
|
headers: headers,
|
|
118
119
|
input_buffer: inp.input.b,
|
|
119
|
-
key: inp.key
|
|
120
|
+
key: inp.key,
|
|
121
|
+
scope: inp.scope,
|
|
122
|
+
limit_key: inp.limit_key,
|
|
123
|
+
idempotency_key: inp.idempotency_key
|
|
120
124
|
)
|
|
121
125
|
end
|
|
122
126
|
|
|
@@ -145,16 +149,19 @@ module Restate
|
|
|
145
149
|
@vm.sys_sleep(millis, name)
|
|
146
150
|
end
|
|
147
151
|
|
|
148
|
-
def sys_call(service:, handler:, parameter:, key: nil, idempotency_key: nil, headers: nil
|
|
149
|
-
|
|
152
|
+
def sys_call(service:, handler:, parameter:, key: nil, idempotency_key: nil, headers: nil,
|
|
153
|
+
scope: nil, limit_key: nil)
|
|
154
|
+
# Rust side expects 8 args:
|
|
155
|
+
# (service, handler, buffer, key_or_nil, idem_key_or_nil, headers_or_nil, scope_or_nil, limit_key_or_nil)
|
|
150
156
|
hdr_array = headers&.map { |k, v| [k, v] }
|
|
151
|
-
@vm.sys_call(service, handler, parameter, key, idempotency_key, hdr_array)
|
|
157
|
+
@vm.sys_call(service, handler, parameter, key, idempotency_key, hdr_array, scope, limit_key)
|
|
152
158
|
end
|
|
153
159
|
|
|
154
|
-
def sys_send(service:, handler:, parameter:, key: nil, delay: nil, idempotency_key: nil, headers: nil
|
|
155
|
-
|
|
160
|
+
def sys_send(service:, handler:, parameter:, key: nil, delay: nil, idempotency_key: nil, headers: nil,
|
|
161
|
+
scope: nil, limit_key: nil)
|
|
162
|
+
# Rust side expects 9 args
|
|
156
163
|
hdr_array = headers&.map { |k, v| [k, v] }
|
|
157
|
-
@vm.sys_send(service, handler, parameter, key, delay, idempotency_key, hdr_array)
|
|
164
|
+
@vm.sys_send(service, handler, parameter, key, delay, idempotency_key, hdr_array, scope, limit_key)
|
|
158
165
|
end
|
|
159
166
|
|
|
160
167
|
def sys_run(name)
|
data/lib/restate/workflow.rb
CHANGED
|
@@ -52,11 +52,14 @@ module Restate
|
|
|
52
52
|
#
|
|
53
53
|
# @example
|
|
54
54
|
# UserSignup.call("user42").run("user@example.com").await
|
|
55
|
+
# UserSignup.call("user42", scope: "tenant1", limit_key: "tenant1/user42").run(email).await
|
|
55
56
|
#
|
|
56
57
|
# @param key [String] the workflow key
|
|
58
|
+
# @param scope [String, nil] optional scope to route the call within (see {Restate.scope})
|
|
59
|
+
# @param limit_key [String, nil] optional concurrency limit key within the scope
|
|
57
60
|
# @return [ServiceCallProxy]
|
|
58
|
-
def self.call(key)
|
|
59
|
-
ServiceCallProxy.new(self, key: key, call_method: :workflow_call)
|
|
61
|
+
def self.call(key, scope: nil, limit_key: nil)
|
|
62
|
+
ServiceCallProxy.new(self, key: key, call_method: :workflow_call, scope: scope, limit_key: limit_key)
|
|
60
63
|
end
|
|
61
64
|
|
|
62
65
|
# Returns a send proxy for fluent fire-and-forget sends to this workflow.
|
|
@@ -64,12 +67,19 @@ module Restate
|
|
|
64
67
|
# @example
|
|
65
68
|
# UserSignup.send!("user42").run("user@example.com")
|
|
66
69
|
# UserSignup.send!("user42", delay: 60).run("user@example.com")
|
|
70
|
+
# UserSignup.send!("user42", scope: "tenant1", limit_key: "tenant1/user42").run(email)
|
|
67
71
|
#
|
|
68
72
|
# @param key [String] the workflow key
|
|
69
73
|
# @param delay [Numeric, nil] optional delay in seconds
|
|
74
|
+
# @param scope [String, nil] optional scope to route the send within (see {Restate.scope})
|
|
75
|
+
# @param limit_key [String, nil] optional concurrency limit key within the scope
|
|
70
76
|
# @return [ServiceSendProxy]
|
|
71
|
-
def self.send!(key, delay: nil)
|
|
72
|
-
ServiceSendProxy.new(
|
|
77
|
+
def self.send!(key, delay: nil, scope: nil, limit_key: nil)
|
|
78
|
+
ServiceSendProxy.new(
|
|
79
|
+
self,
|
|
80
|
+
key: key, send_method: :workflow_send,
|
|
81
|
+
delay: delay, scope: scope, limit_key: limit_key
|
|
82
|
+
)
|
|
73
83
|
end
|
|
74
84
|
|
|
75
85
|
def self._service_kind
|
data/lib/restate.rb
CHANGED
|
@@ -219,15 +219,27 @@ module Restate # rubocop:disable Metrics/ModuleLength
|
|
|
219
219
|
end
|
|
220
220
|
|
|
221
221
|
# Durably call a handler using raw bytes (no serialization).
|
|
222
|
-
def generic_call(service, handler, arg, key: nil, idempotency_key: nil, headers: nil
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
def generic_call(service, handler, arg, key: nil, idempotency_key: nil, headers: nil,
|
|
223
|
+
scope: nil, limit_key: nil)
|
|
224
|
+
fetch_context!.generic_call(service, handler, arg, key: key, idempotency_key: idempotency_key,
|
|
225
|
+
headers: headers, scope: scope, limit_key: limit_key)
|
|
225
226
|
end
|
|
226
227
|
|
|
227
228
|
# Fire-and-forget send using raw bytes (no serialization).
|
|
228
|
-
def generic_send(service, handler, arg, key: nil, delay: nil, idempotency_key: nil, headers: nil
|
|
229
|
+
def generic_send(service, handler, arg, key: nil, delay: nil, idempotency_key: nil, headers: nil,
|
|
230
|
+
scope: nil, limit_key: nil)
|
|
229
231
|
fetch_context!.generic_send(service, handler, arg, key: key, delay: delay,
|
|
230
|
-
idempotency_key: idempotency_key, headers: headers
|
|
232
|
+
idempotency_key: idempotency_key, headers: headers,
|
|
233
|
+
scope: scope, limit_key: limit_key)
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
# Returns a +ScopedContext+ that routes all outgoing calls within the given scope.
|
|
237
|
+
# See {Restate::Context#scope} for the full semantics and constraints.
|
|
238
|
+
#
|
|
239
|
+
# @example
|
|
240
|
+
# Restate.scope("tenant1").service_call(Greeter, :greet, "World", limit_key: "tenant1/user42")
|
|
241
|
+
def scope(scope)
|
|
242
|
+
fetch_context!.scope(scope)
|
|
231
243
|
end
|
|
232
244
|
|
|
233
245
|
# ── Awakeables ──
|
data/sig/restate.rbs
CHANGED
|
@@ -35,8 +35,9 @@ module Restate
|
|
|
35
35
|
def self.object_send: (untyped service, (String | Symbol) handler, String key, untyped arg, ?delay: Numeric?, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?input_serde: untyped) -> SendHandle
|
|
36
36
|
def self.workflow_call: (untyped service, (String | Symbol) handler, String key, untyped arg, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?input_serde: untyped, ?output_serde: untyped) -> DurableCallFuture
|
|
37
37
|
def self.workflow_send: (untyped service, (String | Symbol) handler, String key, untyped arg, ?delay: Numeric?, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?input_serde: untyped) -> SendHandle
|
|
38
|
-
def self.generic_call: (String service, String handler, String arg, ?key: String?, ?idempotency_key: String?, ?headers: Hash[String, String]?) -> DurableCallFuture
|
|
39
|
-
def self.generic_send: (String service, String handler, String arg, ?key: String?, ?delay: Numeric?, ?idempotency_key: String?, ?headers: Hash[String, String]?) -> SendHandle
|
|
38
|
+
def self.generic_call: (String service, String handler, String arg, ?key: String?, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?scope: String?, ?limit_key: String?) -> DurableCallFuture
|
|
39
|
+
def self.generic_send: (String service, String handler, String arg, ?key: String?, ?delay: Numeric?, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?scope: String?, ?limit_key: String?) -> SendHandle
|
|
40
|
+
def self.scope: (String scope) -> Server::ScopedContext
|
|
40
41
|
|
|
41
42
|
# ── Awakeables ──
|
|
42
43
|
|
|
@@ -197,11 +198,11 @@ module Restate
|
|
|
197
198
|
# ── Service proxies ──
|
|
198
199
|
|
|
199
200
|
class ServiceCallProxy
|
|
200
|
-
def initialize: (untyped service_class, ?key: String?, ?call_method: Symbol) -> void
|
|
201
|
+
def initialize: (untyped service_class, ?key: String?, ?call_method: Symbol, ?scope: String?, ?limit_key: String?) -> void
|
|
201
202
|
end
|
|
202
203
|
|
|
203
204
|
class ServiceSendProxy
|
|
204
|
-
def initialize: (untyped service_class, ?key: String?, ?send_method: Symbol, ?delay: Numeric?) -> void
|
|
205
|
+
def initialize: (untyped service_class, ?key: String?, ?send_method: Symbol, ?delay: Numeric?, ?scope: String?, ?limit_key: String?) -> void
|
|
205
206
|
end
|
|
206
207
|
|
|
207
208
|
# ── Service classes (declared but not checked — heavy metaprogramming) ──
|
|
@@ -225,6 +226,16 @@ module Restate
|
|
|
225
226
|
|
|
226
227
|
class Context
|
|
227
228
|
end
|
|
229
|
+
|
|
230
|
+
class ScopedContext
|
|
231
|
+
def initialize: (untyped ctx, String scope) -> void
|
|
232
|
+
def service_call: (untyped service, (String | Symbol) handler, untyped arg, ?key: String?, ?limit_key: String?, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?input_serde: untyped, ?output_serde: untyped) -> DurableCallFuture
|
|
233
|
+
def service_send: (untyped service, (String | Symbol) handler, untyped arg, ?key: String?, ?delay: Numeric?, ?limit_key: String?, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?input_serde: untyped) -> SendHandle
|
|
234
|
+
def object_call: (untyped service, (String | Symbol) handler, String key, untyped arg, ?limit_key: String?, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?input_serde: untyped, ?output_serde: untyped) -> DurableCallFuture
|
|
235
|
+
def object_send: (untyped service, (String | Symbol) handler, String key, untyped arg, ?delay: Numeric?, ?limit_key: String?, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?input_serde: untyped) -> SendHandle
|
|
236
|
+
def workflow_call: (untyped service, (String | Symbol) handler, String key, untyped arg, ?limit_key: String?, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?input_serde: untyped, ?output_serde: untyped) -> DurableCallFuture
|
|
237
|
+
def workflow_send: (untyped service, (String | Symbol) handler, String key, untyped arg, ?delay: Numeric?, ?limit_key: String?, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?input_serde: untyped) -> SendHandle
|
|
238
|
+
end
|
|
228
239
|
end
|
|
229
240
|
|
|
230
241
|
module JsonSerde
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: restate-sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Restate Developers
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-07-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: async
|