restate-sdk 0.6.0 → 0.8.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 +1 -1
- data/README.md +31 -14
- data/ext/restate_internal/Cargo.toml +1 -1
- data/lib/restate/client.rb +157 -0
- data/lib/restate/config.rb +35 -0
- data/lib/restate/context.rb +13 -128
- data/lib/restate/discovery.rb +6 -15
- data/lib/restate/durable_future.rb +15 -39
- data/lib/restate/endpoint.rb +5 -22
- data/lib/restate/errors.rb +2 -15
- data/lib/restate/handler.rb +21 -20
- data/lib/restate/serde.rb +14 -130
- data/lib/restate/server.rb +10 -26
- data/lib/restate/server_context.rb +50 -248
- data/lib/restate/service.rb +24 -3
- data/lib/restate/service_dsl.rb +70 -6
- data/lib/restate/service_proxy.rb +73 -0
- data/lib/restate/testing.rb +1 -1
- data/lib/restate/version.rb +2 -2
- data/lib/restate/virtual_object.rb +27 -4
- data/lib/restate/vm.rb +9 -74
- data/lib/restate/workflow.rb +27 -4
- data/lib/restate.rb +222 -62
- data/sig/restate.rbs +196 -0
- metadata +6 -18
- data/lib/tapioca/dsl/compilers/restate.rb +0 -116
- data/rbi/restate-sdk.rbi +0 -307
data/lib/restate.rb
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# typed: true
|
|
2
2
|
# frozen_string_literal: true
|
|
3
3
|
|
|
4
|
-
require 'sorbet-runtime'
|
|
5
4
|
require_relative 'restate/version'
|
|
6
5
|
require_relative 'restate/errors'
|
|
7
6
|
require_relative 'restate/serde'
|
|
@@ -16,11 +15,21 @@ require_relative 'restate/server_context'
|
|
|
16
15
|
require_relative 'restate/durable_future'
|
|
17
16
|
require_relative 'restate/discovery'
|
|
18
17
|
require_relative 'restate/endpoint'
|
|
18
|
+
require_relative 'restate/service_proxy'
|
|
19
|
+
require_relative 'restate/config'
|
|
20
|
+
require_relative 'restate/client'
|
|
19
21
|
|
|
20
22
|
# Restate Ruby SDK — build resilient applications with durable execution.
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
#
|
|
24
|
+
# All handler-facing operations are available as module methods on +Restate+.
|
|
25
|
+
# Inside a handler, call +Restate.run_sync+, +Restate.sleep+, +Restate.get+,
|
|
26
|
+
# etc. directly — no context parameter needed.
|
|
27
|
+
#
|
|
28
|
+
# The context is stored in +Thread.current[]+ (fiber-scoped in Ruby 3.0+).
|
|
29
|
+
# We intentionally use +Thread.current[]+ rather than +Fiber[]+ (Ruby 3.2+)
|
|
30
|
+
# because +Thread.current[]+ is NOT inherited by child fibers, which prevents
|
|
31
|
+
# accidental context leaks when Async spawns child tasks for run blocks.
|
|
32
|
+
module Restate # rubocop:disable Metrics/ModuleLength
|
|
24
33
|
module_function
|
|
25
34
|
|
|
26
35
|
# Create an endpoint, optionally binding services.
|
|
@@ -28,13 +37,6 @@ module Restate
|
|
|
28
37
|
#
|
|
29
38
|
# @param services [Array<Class>] service classes or instances to bind
|
|
30
39
|
# @return [Endpoint]
|
|
31
|
-
sig do
|
|
32
|
-
params(
|
|
33
|
-
services: T.untyped,
|
|
34
|
-
protocol: T.nilable(String),
|
|
35
|
-
identity_keys: T.nilable(T::Array[String])
|
|
36
|
-
).returns(Endpoint)
|
|
37
|
-
end
|
|
38
40
|
def endpoint(*services, protocol: nil, identity_keys: nil)
|
|
39
41
|
ep = Endpoint.new
|
|
40
42
|
ep.streaming_protocol if protocol == 'bidi'
|
|
@@ -44,71 +46,46 @@ module Restate
|
|
|
44
46
|
ep
|
|
45
47
|
end
|
|
46
48
|
|
|
47
|
-
# ──
|
|
48
|
-
#
|
|
49
|
-
# The SDK passes the context as the first argument to every handler.
|
|
50
|
-
# It is also stored in fiber-local storage (Thread.current[], which is
|
|
51
|
-
# fiber-scoped in Ruby). These methods retrieve it with the appropriate
|
|
52
|
-
# type for IDE completion.
|
|
53
|
-
#
|
|
54
|
-
# Use these from nested helper methods that don't have +ctx+ in scope.
|
|
55
|
-
|
|
56
|
-
# Returns the current context for a Service handler.
|
|
57
|
-
# Raises if called outside a Restate handler.
|
|
58
|
-
#
|
|
59
|
-
# @return [Context]
|
|
60
|
-
sig { returns(Context) }
|
|
61
|
-
def current_context
|
|
62
|
-
fetch_context!
|
|
63
|
-
end
|
|
49
|
+
# ── Global configuration ──
|
|
64
50
|
|
|
65
|
-
#
|
|
66
|
-
# Raises if not inside a VirtualObject exclusive handler.
|
|
51
|
+
# Configure the SDK globally. Settings are used by +Restate.client+.
|
|
67
52
|
#
|
|
68
|
-
# @
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
# @example
|
|
54
|
+
# Restate.configure do |c|
|
|
55
|
+
# c.ingress_url = "http://localhost:8080"
|
|
56
|
+
# c.admin_url = "http://localhost:9070"
|
|
57
|
+
# end
|
|
58
|
+
def configure(&)
|
|
59
|
+
yield config
|
|
72
60
|
end
|
|
73
61
|
|
|
74
|
-
# Returns the
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
# @return [ObjectSharedContext]
|
|
79
|
-
sig { returns(ObjectSharedContext) }
|
|
80
|
-
def current_shared_context
|
|
81
|
-
fetch_context!(service_kind: 'object', handler_kind: 'shared')
|
|
62
|
+
# Returns the global configuration. Creates a default one on first access.
|
|
63
|
+
def config
|
|
64
|
+
@config = nil unless defined?(@config)
|
|
65
|
+
@config ||= Config.new
|
|
82
66
|
end
|
|
83
67
|
|
|
84
|
-
# Returns
|
|
85
|
-
#
|
|
68
|
+
# Returns a pre-configured Client using the global +config+.
|
|
69
|
+
# Creates a new Client on each call (stateless — safe to discard).
|
|
86
70
|
#
|
|
87
|
-
# @
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
71
|
+
# @example
|
|
72
|
+
# Restate.client.service(Greeter).greet("World")
|
|
73
|
+
# Restate.client.resolve_awakeable(id, payload)
|
|
74
|
+
# Restate.client.create_deployment("http://localhost:9080")
|
|
75
|
+
def client
|
|
76
|
+
cfg = config
|
|
77
|
+
Client.new(ingress_url: cfg.ingress_url, admin_url: cfg.admin_url,
|
|
78
|
+
ingress_headers: cfg.ingress_headers, admin_headers: cfg.admin_headers)
|
|
91
79
|
end
|
|
92
80
|
|
|
93
|
-
#
|
|
94
|
-
# Read-only state: +get+ and +state_keys+ only, no +set+/+clear+.
|
|
95
|
-
# Raises if not inside a Workflow shared handler.
|
|
96
|
-
#
|
|
97
|
-
# @return [WorkflowSharedContext]
|
|
98
|
-
sig { returns(WorkflowSharedContext) }
|
|
99
|
-
def current_shared_workflow_context
|
|
100
|
-
fetch_context!(service_kind: 'workflow', handler_kind: 'shared')
|
|
101
|
-
end
|
|
81
|
+
# ── Context accessor (internal) ──
|
|
102
82
|
|
|
103
83
|
# @!visibility private
|
|
104
|
-
sig do
|
|
105
|
-
params(service_kind: T.nilable(String), handler_kind: T.nilable(String)).returns(ServerContext)
|
|
106
|
-
end
|
|
107
84
|
def fetch_context!(service_kind: nil, handler_kind: nil) # rubocop:disable Metrics
|
|
108
85
|
ctx = Thread.current[:restate_context]
|
|
109
86
|
unless ctx
|
|
110
87
|
Kernel.raise 'Not inside a Restate handler. ' \
|
|
111
|
-
'
|
|
88
|
+
'Restate.* methods can only be called during handler execution.'
|
|
112
89
|
end
|
|
113
90
|
|
|
114
91
|
if service_kind
|
|
@@ -125,6 +102,189 @@ module Restate
|
|
|
125
102
|
end
|
|
126
103
|
end
|
|
127
104
|
|
|
128
|
-
|
|
105
|
+
ctx
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# ── Durable execution ──
|
|
109
|
+
|
|
110
|
+
# Execute a durable side effect. The block runs at most once; the result
|
|
111
|
+
# is journaled and replayed on retries. Returns a DurableFuture.
|
|
112
|
+
def run(name, serde: JsonSerde, retry_policy: nil, background: false, &action)
|
|
113
|
+
fetch_context!.run(name, serde: serde, retry_policy: retry_policy, background: background, &action)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Convenience shortcut for +run(...).await+. Returns the result directly.
|
|
117
|
+
def run_sync(name, serde: JsonSerde, retry_policy: nil, background: false, &action)
|
|
118
|
+
fetch_context!.run_sync(name, serde: serde, retry_policy: retry_policy, background: background, &action)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Durable timer that survives handler restarts.
|
|
122
|
+
def sleep(seconds)
|
|
123
|
+
fetch_context!.sleep(seconds)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
# ── State operations (VirtualObject / Workflow) ──
|
|
127
|
+
|
|
128
|
+
# Durably retrieve a state entry. Returns nil if unset.
|
|
129
|
+
def get(name, serde: JsonSerde)
|
|
130
|
+
fetch_context!.get(name, serde: serde)
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Durably retrieve a state entry, returning a DurableFuture instead of blocking.
|
|
134
|
+
def get_async(name, serde: JsonSerde)
|
|
135
|
+
fetch_context!.get_async(name, serde: serde)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Durably set a state entry.
|
|
139
|
+
def set(name, value, serde: JsonSerde)
|
|
140
|
+
fetch_context!.set(name, value, serde: serde)
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
# Durably remove a single state entry.
|
|
144
|
+
def clear(name)
|
|
145
|
+
fetch_context!.clear(name)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Durably remove all state entries.
|
|
149
|
+
def clear_all
|
|
150
|
+
fetch_context!.clear_all
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# List all state entry names.
|
|
154
|
+
def state_keys
|
|
155
|
+
fetch_context!.state_keys
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# List all state entry names, returning a DurableFuture.
|
|
159
|
+
def state_keys_async
|
|
160
|
+
fetch_context!.state_keys_async
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# ── Service communication ──
|
|
164
|
+
|
|
165
|
+
# Durably call a handler on a Restate service.
|
|
166
|
+
def service_call(service, handler, arg, key: nil, idempotency_key: nil, headers: nil,
|
|
167
|
+
input_serde: NOT_SET, output_serde: NOT_SET)
|
|
168
|
+
ctx = fetch_context!
|
|
169
|
+
ctx.service_call(service, handler, arg, key: key, idempotency_key: idempotency_key,
|
|
170
|
+
headers: headers, input_serde: input_serde, output_serde: output_serde)
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# Fire-and-forget send to a Restate service handler.
|
|
174
|
+
def service_send(service, handler, arg, key: nil, delay: nil, idempotency_key: nil,
|
|
175
|
+
headers: nil, input_serde: NOT_SET)
|
|
176
|
+
ctx = fetch_context!
|
|
177
|
+
ctx.service_send(service, handler, arg, key: key, delay: delay, idempotency_key: idempotency_key,
|
|
178
|
+
headers: headers, input_serde: input_serde)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Durably call a handler on a Restate virtual object.
|
|
182
|
+
def object_call(service, handler, key, arg, idempotency_key: nil, headers: nil,
|
|
183
|
+
input_serde: NOT_SET, output_serde: NOT_SET)
|
|
184
|
+
ctx = fetch_context!
|
|
185
|
+
ctx.object_call(service, handler, key, arg, idempotency_key: idempotency_key,
|
|
186
|
+
headers: headers, input_serde: input_serde, output_serde: output_serde)
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
# Fire-and-forget send to a Restate virtual object handler.
|
|
190
|
+
def object_send(service, handler, key, arg, delay: nil, idempotency_key: nil,
|
|
191
|
+
headers: nil, input_serde: NOT_SET)
|
|
192
|
+
ctx = fetch_context!
|
|
193
|
+
ctx.object_send(service, handler, key, arg, delay: delay, idempotency_key: idempotency_key,
|
|
194
|
+
headers: headers, input_serde: input_serde)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
# Durably call a handler on a Restate workflow.
|
|
198
|
+
def workflow_call(service, handler, key, arg, idempotency_key: nil, headers: nil,
|
|
199
|
+
input_serde: NOT_SET, output_serde: NOT_SET)
|
|
200
|
+
ctx = fetch_context!
|
|
201
|
+
ctx.workflow_call(service, handler, key, arg,
|
|
202
|
+
idempotency_key: idempotency_key, headers: headers,
|
|
203
|
+
input_serde: input_serde, output_serde: output_serde)
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Fire-and-forget send to a Restate workflow handler.
|
|
207
|
+
def workflow_send(service, handler, key, arg, delay: nil, idempotency_key: nil,
|
|
208
|
+
headers: nil, input_serde: NOT_SET)
|
|
209
|
+
ctx = fetch_context!
|
|
210
|
+
ctx.workflow_send(service, handler, key, arg, delay: delay, idempotency_key: idempotency_key,
|
|
211
|
+
headers: headers, input_serde: input_serde)
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Durably call a handler using raw bytes (no serialization).
|
|
215
|
+
def generic_call(service, handler, arg, key: nil, idempotency_key: nil, headers: nil)
|
|
216
|
+
fetch_context!.generic_call(service, handler, arg, key: key,
|
|
217
|
+
idempotency_key: idempotency_key, headers: headers)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Fire-and-forget send using raw bytes (no serialization).
|
|
221
|
+
def generic_send(service, handler, arg, key: nil, delay: nil, idempotency_key: nil, headers: nil)
|
|
222
|
+
fetch_context!.generic_send(service, handler, arg, key: key, delay: delay,
|
|
223
|
+
idempotency_key: idempotency_key, headers: headers)
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# ── Awakeables ──
|
|
227
|
+
|
|
228
|
+
# Create an awakeable for external callbacks. Returns [awakeable_id, DurableFuture].
|
|
229
|
+
def awakeable(serde: JsonSerde)
|
|
230
|
+
fetch_context!.awakeable(serde: serde)
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# Resolve an awakeable with a success value.
|
|
234
|
+
def resolve_awakeable(awakeable_id, payload, serde: JsonSerde)
|
|
235
|
+
fetch_context!.resolve_awakeable(awakeable_id, payload, serde: serde)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
# Reject an awakeable with a terminal failure.
|
|
239
|
+
def reject_awakeable(awakeable_id, message, code: 500)
|
|
240
|
+
fetch_context!.reject_awakeable(awakeable_id, message, code: code)
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
# ── Promises (Workflow only) ──
|
|
244
|
+
|
|
245
|
+
# Get a durable promise value, blocking until resolved.
|
|
246
|
+
def promise(name, serde: JsonSerde)
|
|
247
|
+
fetch_context!.promise(name, serde: serde)
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Peek at a durable promise without blocking. Returns nil if not yet resolved.
|
|
251
|
+
def peek_promise(name, serde: JsonSerde)
|
|
252
|
+
fetch_context!.peek_promise(name, serde: serde)
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
# Resolve a durable promise with a value.
|
|
256
|
+
def resolve_promise(name, payload, serde: JsonSerde)
|
|
257
|
+
fetch_context!.resolve_promise(name, payload, serde: serde)
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
# Reject a durable promise with a terminal failure.
|
|
261
|
+
def reject_promise(name, message, code: 500)
|
|
262
|
+
fetch_context!.reject_promise(name, message, code: code)
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
# ── Futures ──
|
|
266
|
+
|
|
267
|
+
# Wait until any of the given futures completes. Returns [completed, remaining].
|
|
268
|
+
def wait_any(*futures)
|
|
269
|
+
fetch_context!.wait_any(*futures)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# ── Request metadata ──
|
|
273
|
+
|
|
274
|
+
# Returns metadata about the current invocation (id, headers, raw body).
|
|
275
|
+
def request
|
|
276
|
+
fetch_context!.request
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# Returns the key for this virtual object or workflow invocation.
|
|
280
|
+
def key
|
|
281
|
+
fetch_context!.key
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# ── Invocation control ──
|
|
285
|
+
|
|
286
|
+
# Request cancellation of another invocation.
|
|
287
|
+
def cancel_invocation(invocation_id)
|
|
288
|
+
fetch_context!.cancel_invocation(invocation_id)
|
|
129
289
|
end
|
|
130
290
|
end
|
data/sig/restate.rbs
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Public API type signatures for the Restate Ruby SDK.
|
|
2
|
+
# Used by Steep for static type checking and by Ruby LSP for IDE completion.
|
|
3
|
+
|
|
4
|
+
module Restate
|
|
5
|
+
# ── Endpoint ──
|
|
6
|
+
|
|
7
|
+
def self.endpoint: (*untyped services, ?protocol: String?, ?identity_keys: Array[String]?) -> Endpoint
|
|
8
|
+
def self.configure: () { (Config) -> void } -> void
|
|
9
|
+
def self.config: () -> Config
|
|
10
|
+
def self.client: () -> Client
|
|
11
|
+
|
|
12
|
+
# ── Durable execution ──
|
|
13
|
+
|
|
14
|
+
def self.run: (String name, ?serde: untyped, ?retry_policy: untyped, ?background: bool) { () -> untyped } -> DurableFuture
|
|
15
|
+
def self.run_sync: (String name, ?serde: untyped, ?retry_policy: untyped, ?background: bool) { () -> untyped } -> untyped
|
|
16
|
+
def self.sleep: (Numeric seconds) -> DurableFuture
|
|
17
|
+
|
|
18
|
+
# ── State operations ──
|
|
19
|
+
|
|
20
|
+
def self.get: (String name, ?serde: untyped) -> untyped
|
|
21
|
+
def self.get_async: (String name, ?serde: untyped) -> DurableFuture
|
|
22
|
+
def self.set: (String name, untyped value, ?serde: untyped) -> void
|
|
23
|
+
def self.clear: (String name) -> void
|
|
24
|
+
def self.clear_all: () -> void
|
|
25
|
+
def self.state_keys: () -> Array[String]
|
|
26
|
+
def self.state_keys_async: () -> DurableFuture
|
|
27
|
+
|
|
28
|
+
# ── Service communication ──
|
|
29
|
+
|
|
30
|
+
def self.service_call: (untyped service, (String | Symbol) handler, untyped arg, ?key: String?, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?input_serde: untyped, ?output_serde: untyped) -> DurableCallFuture
|
|
31
|
+
def self.service_send: (untyped service, (String | Symbol) handler, untyped arg, ?key: String?, ?delay: Numeric?, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?input_serde: untyped) -> SendHandle
|
|
32
|
+
def self.object_call: (untyped service, (String | Symbol) handler, String key, untyped arg, ?idempotency_key: String?, ?headers: Hash[String, String]?, ?input_serde: untyped, ?output_serde: untyped) -> DurableCallFuture
|
|
33
|
+
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
|
|
34
|
+
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
|
|
35
|
+
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
|
|
36
|
+
def self.generic_call: (String service, String handler, String arg, ?key: String?, ?idempotency_key: String?, ?headers: Hash[String, String]?) -> DurableCallFuture
|
|
37
|
+
def self.generic_send: (String service, String handler, String arg, ?key: String?, ?delay: Numeric?, ?idempotency_key: String?, ?headers: Hash[String, String]?) -> SendHandle
|
|
38
|
+
|
|
39
|
+
# ── Awakeables ──
|
|
40
|
+
|
|
41
|
+
def self.awakeable: (?serde: untyped) -> [String, DurableFuture]
|
|
42
|
+
def self.resolve_awakeable: (String awakeable_id, untyped payload, ?serde: untyped) -> void
|
|
43
|
+
def self.reject_awakeable: (String awakeable_id, String message, ?code: Integer) -> void
|
|
44
|
+
|
|
45
|
+
# ── Promises ──
|
|
46
|
+
|
|
47
|
+
def self.promise: (String name, ?serde: untyped) -> untyped
|
|
48
|
+
def self.peek_promise: (String name, ?serde: untyped) -> untyped
|
|
49
|
+
def self.resolve_promise: (String name, untyped payload, ?serde: untyped) -> void
|
|
50
|
+
def self.reject_promise: (String name, String message, ?code: Integer) -> void
|
|
51
|
+
|
|
52
|
+
# ── Futures / Metadata / Control ──
|
|
53
|
+
|
|
54
|
+
def self.wait_any: (*DurableFuture futures) -> [Array[DurableFuture], Array[DurableFuture]]
|
|
55
|
+
def self.request: () -> untyped
|
|
56
|
+
def self.key: () -> String
|
|
57
|
+
def self.cancel_invocation: (String invocation_id) -> void
|
|
58
|
+
def self.fetch_context!: (?service_kind: String?, ?handler_kind: String?) -> untyped
|
|
59
|
+
|
|
60
|
+
# ── Errors ──
|
|
61
|
+
|
|
62
|
+
class TerminalError < StandardError
|
|
63
|
+
attr_reader status_code: Integer
|
|
64
|
+
def initialize: (?String message, ?status_code: Integer) -> void
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class SuspendedError < StandardError
|
|
68
|
+
def initialize: () -> void
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
class InternalError < StandardError
|
|
72
|
+
def initialize: () -> void
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
class DisconnectedError < StandardError
|
|
76
|
+
def initialize: () -> void
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# ── Futures ──
|
|
80
|
+
|
|
81
|
+
class DurableFuture
|
|
82
|
+
attr_reader handle: Integer
|
|
83
|
+
def initialize: (untyped ctx, Integer handle, ?serde: untyped) -> void
|
|
84
|
+
def await: () -> untyped
|
|
85
|
+
def completed?: () -> bool
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
class DurableCallFuture < DurableFuture
|
|
89
|
+
def initialize: (untyped ctx, Integer result_handle, Integer invocation_id_handle, output_serde: untyped) -> void
|
|
90
|
+
def invocation_id: () -> String
|
|
91
|
+
def cancel: () -> void
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
class SendHandle
|
|
95
|
+
def initialize: (untyped ctx, Integer invocation_id_handle) -> void
|
|
96
|
+
def invocation_id: () -> String
|
|
97
|
+
def cancel: () -> void
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# ── Config ──
|
|
101
|
+
|
|
102
|
+
class Config
|
|
103
|
+
attr_accessor ingress_url: String
|
|
104
|
+
attr_accessor admin_url: String
|
|
105
|
+
attr_accessor ingress_headers: Hash[String, String]
|
|
106
|
+
attr_accessor admin_headers: Hash[String, String]
|
|
107
|
+
def initialize: () -> void
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# ── Client ──
|
|
111
|
+
|
|
112
|
+
class Client
|
|
113
|
+
def initialize: (?ingress_url: String, ?admin_url: String, ?ingress_headers: Hash[String, String], ?admin_headers: Hash[String, String]) -> void
|
|
114
|
+
def service: (untyped service) -> ClientServiceProxy
|
|
115
|
+
def object: (untyped service, String key) -> ClientServiceProxy
|
|
116
|
+
def workflow: (untyped service, String key) -> ClientServiceProxy
|
|
117
|
+
def resolve_awakeable: (String awakeable_id, untyped payload) -> void
|
|
118
|
+
def reject_awakeable: (String awakeable_id, String message, ?code: Integer) -> void
|
|
119
|
+
def cancel_invocation: (String invocation_id) -> void
|
|
120
|
+
def kill_invocation: (String invocation_id) -> void
|
|
121
|
+
|
|
122
|
+
private
|
|
123
|
+
|
|
124
|
+
def resolve_name: (untyped service) -> String
|
|
125
|
+
def post_ingress: (String path, untyped body) -> untyped
|
|
126
|
+
def post_admin: (String path, untyped body) -> untyped
|
|
127
|
+
def parse_response: (Net::HTTPResponse response) -> untyped
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
class ClientServiceProxy
|
|
131
|
+
def initialize: (String base_url, String service_name, String? key, Hash[String, String] headers) -> void
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# ── Endpoint ──
|
|
135
|
+
|
|
136
|
+
class Endpoint
|
|
137
|
+
attr_reader services: Hash[String, untyped]
|
|
138
|
+
attr_reader identity_keys: Array[String]
|
|
139
|
+
attr_accessor protocol: String?
|
|
140
|
+
attr_reader middleware: Array[untyped]
|
|
141
|
+
def initialize: () -> void
|
|
142
|
+
def bind: (*untyped svcs) -> self
|
|
143
|
+
def streaming_protocol: () -> self
|
|
144
|
+
def request_response_protocol: () -> self
|
|
145
|
+
def identity_key: (String key) -> self
|
|
146
|
+
def use: (untyped klass, *untyped args, **untyped kwargs) -> self
|
|
147
|
+
def app: () -> untyped
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# ── Service proxies ──
|
|
151
|
+
|
|
152
|
+
class ServiceCallProxy
|
|
153
|
+
def initialize: (untyped service_class, ?key: String?, ?call_method: Symbol) -> void
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
class ServiceSendProxy
|
|
157
|
+
def initialize: (untyped service_class, ?key: String?, ?send_method: Symbol, ?delay: Numeric?) -> void
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# ── Service classes (declared but not checked — heavy metaprogramming) ──
|
|
161
|
+
|
|
162
|
+
class Service
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
class VirtualObject
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
class Workflow
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
# ── Internal ──
|
|
172
|
+
|
|
173
|
+
class Server
|
|
174
|
+
def initialize: (untyped endpoint) -> void
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
module JsonSerde
|
|
178
|
+
def self.serialize: (untyped obj) -> String
|
|
179
|
+
def self.deserialize: (String? buf) -> untyped
|
|
180
|
+
def self.json_schema: () -> Hash[String, untyped]?
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
module BytesSerde
|
|
184
|
+
def self.serialize: (untyped obj) -> String
|
|
185
|
+
def self.deserialize: (String? buf) -> String?
|
|
186
|
+
def self.json_schema: () -> Hash[String, untyped]?
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
class AttemptFinishedEvent
|
|
190
|
+
def set?: () -> bool
|
|
191
|
+
def wait: () -> void
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
NOT_SET: untyped
|
|
195
|
+
RunRetryPolicy: untyped
|
|
196
|
+
end
|
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: 0.
|
|
4
|
+
version: 0.8.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-03-
|
|
11
|
+
date: 2026-03-23 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: async
|
|
@@ -38,20 +38,6 @@ dependencies:
|
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '2.0'
|
|
41
|
-
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: sorbet-runtime
|
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
|
44
|
-
requirements:
|
|
45
|
-
- - ">="
|
|
46
|
-
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
48
|
-
type: :runtime
|
|
49
|
-
prerelease: false
|
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
-
requirements:
|
|
52
|
-
- - ">="
|
|
53
|
-
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
55
41
|
description: Build resilient applications with distributed durable async/await using
|
|
56
42
|
Restate
|
|
57
43
|
email:
|
|
@@ -69,6 +55,8 @@ files:
|
|
|
69
55
|
- ext/restate_internal/extconf.rb
|
|
70
56
|
- ext/restate_internal/src/lib.rs
|
|
71
57
|
- lib/restate.rb
|
|
58
|
+
- lib/restate/client.rb
|
|
59
|
+
- lib/restate/config.rb
|
|
72
60
|
- lib/restate/context.rb
|
|
73
61
|
- lib/restate/discovery.rb
|
|
74
62
|
- lib/restate/durable_future.rb
|
|
@@ -80,13 +68,13 @@ files:
|
|
|
80
68
|
- lib/restate/server_context.rb
|
|
81
69
|
- lib/restate/service.rb
|
|
82
70
|
- lib/restate/service_dsl.rb
|
|
71
|
+
- lib/restate/service_proxy.rb
|
|
83
72
|
- lib/restate/testing.rb
|
|
84
73
|
- lib/restate/version.rb
|
|
85
74
|
- lib/restate/virtual_object.rb
|
|
86
75
|
- lib/restate/vm.rb
|
|
87
76
|
- lib/restate/workflow.rb
|
|
88
|
-
-
|
|
89
|
-
- rbi/restate-sdk.rbi
|
|
77
|
+
- sig/restate.rbs
|
|
90
78
|
homepage: https://github.com/restatedev/sdk-ruby
|
|
91
79
|
licenses:
|
|
92
80
|
- MIT
|