restate-sdk 0.6.0-aarch64-linux → 0.8.0-aarch64-linux

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08c58b099881b9e29b7916d8fdf889061deec26b3cd10cdaba26b3d1a0a5411b'
4
- data.tar.gz: a2ed4acff5fd49fdcf35010a5f5ebfddf0c117eac4adf3a7741f18130d9a4461
3
+ metadata.gz: 3d6b44b67a72794c5def96163fbc7a1a134180ddca5477083468a2d88720b756
4
+ data.tar.gz: 36032a61a77ba21adde9b2cf2aede6456812fc4a40ec98bb082cc5e2a5676ae3
5
5
  SHA512:
6
- metadata.gz: 7f1cb8d1b8ffcbb86da980bbfcb80f378a8649b7747916690f51541c0777453adb14e963c1ee2f2250d062eb02ce6234b5b68d104887d326301a71ef40a78057
7
- data.tar.gz: 8f0e41f655233dde1afd08dc2d722019c20ca0f105497bc147d08c7d657b9631c7f42e170e840a21806173acffaa089609929701a4cba3c37c3a05bcb7fe69df
6
+ metadata.gz: ec7cef72a64b0158f9a6bec982d6ec68718133ad527b5fbc0e9d30969bad539cbb5e4427eb98877d42c6a947fd5bcae080ed235097a31c0cf119e648f12fc03c
7
+ data.tar.gz: d7c3432a6a02c9442d56b164d1de390899683bc20b2775392cff1515fbc234bb84d36515c67a23926c4945386e9cf481dbaead5ed7a8a6f73f91959a4496dd7b
data/Cargo.lock CHANGED
@@ -569,7 +569,7 @@ dependencies = [
569
569
 
570
570
  [[package]]
571
571
  name = "restate_internal"
572
- version = "0.6.0"
572
+ version = "0.8.0"
573
573
  dependencies = [
574
574
  "magnus",
575
575
  "rb-sys",
data/README.md CHANGED
@@ -13,8 +13,20 @@
13
13
  require 'restate'
14
14
 
15
15
  class Greeter < Restate::Service
16
- handler def greet(ctx, name)
17
- ctx.run_sync('build-greeting') { "Hello, #{name}!" }
16
+ handler def greet(name)
17
+ Restate.run_sync('build-greeting') { "Hello, #{name}!" }
18
+ end
19
+ end
20
+
21
+ class Counter < Restate::VirtualObject
22
+ state :count, default: 0
23
+
24
+ handler def add(addend)
25
+ self.count += addend
26
+ end
27
+
28
+ shared def get
29
+ count
18
30
  end
19
31
  end
20
32
  ```
@@ -46,29 +58,34 @@ Or add the gem to an existing project:
46
58
  gem install restate-sdk
47
59
  ```
48
60
 
49
- ### Typed handlers with T::Struct
61
+ ### Typed handlers with Dry::Struct
50
62
 
51
- Use Sorbet's `T::Struct` for typed input/output with automatic JSON Schema generation:
63
+ Use [dry-struct](https://dry-rb.org/gems/dry-struct/) for typed input/output with automatic JSON Schema generation:
52
64
 
53
65
  ```ruby
54
66
  require 'restate'
67
+ require 'dry-struct'
68
+
69
+ module Types
70
+ include Dry.Types()
71
+ end
55
72
 
56
- class RegistrationRequest < T::Struct
57
- const :event_name, String
58
- const :attendee, String
59
- const :num_guests, Integer
60
- const :note, T.nilable(String)
73
+ class RegistrationRequest < Dry::Struct
74
+ attribute :event_name, Types::String
75
+ attribute :attendee, Types::String
76
+ attribute :num_guests, Types::Integer
77
+ attribute? :note, Types::String # optional attribute
61
78
  end
62
79
 
63
- class RegistrationResponse < T::Struct
64
- const :registration_id, String
65
- const :status, String
80
+ class RegistrationResponse < Dry::Struct
81
+ attribute :registration_id, Types::String
82
+ attribute :status, Types::String
66
83
  end
67
84
 
68
85
  class EventService < Restate::Service
69
86
  handler :register, input: RegistrationRequest, output: RegistrationResponse
70
- def register(ctx, request)
71
- registration_id = ctx.run_sync('create-registration') do
87
+ def register(request)
88
+ registration_id = Restate.run_sync('create-registration') do
72
89
  "reg_#{request.event_name}_#{rand(10_000)}"
73
90
  end
74
91
 
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "restate_internal"
3
- version = "0.6.0"
3
+ version = "0.8.0"
4
4
  edition = "2021"
5
5
  publish = false
6
6
 
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,157 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ require 'net/http'
5
+ require 'json'
6
+
7
+ module Restate
8
+ # HTTP client for invoking Restate services and managing the Restate runtime
9
+ # from outside the Restate runtime.
10
+ #
11
+ # @example Via global config (recommended)
12
+ # Restate.configure do |c|
13
+ # c.ingress_url = "http://localhost:8080"
14
+ # c.admin_url = "http://localhost:9070"
15
+ # end
16
+ # client = Restate.client
17
+ # result = client.service(Greeter).greet("World")
18
+ #
19
+ # @example Standalone
20
+ # client = Restate::Client.new(ingress_url: "http://localhost:8080",
21
+ # admin_url: "http://localhost:9070")
22
+ #
23
+ # @example Service invocation
24
+ # client.service("Greeter").greet("World")
25
+ # client.object("Counter", "my-key").add(5)
26
+ # client.workflow("UserSignup", "user42").run("user@example.com")
27
+ #
28
+ # @example Admin operations
29
+ # client.resolve_awakeable(awakeable_id, "result")
30
+ # client.reject_awakeable(awakeable_id, "failed")
31
+ # client.cancel_invocation(invocation_id)
32
+ # client.create_deployment("http://localhost:9080")
33
+ class Client
34
+ def initialize(ingress_url: 'http://localhost:8080', admin_url: 'http://localhost:9070',
35
+ ingress_headers: {}, admin_headers: {})
36
+ @ingress_url = ingress_url.chomp('/')
37
+ @admin_url = admin_url.chomp('/')
38
+ @ingress_headers = ingress_headers
39
+ @admin_headers = admin_headers
40
+ end
41
+
42
+ # ── Service invocation proxies ──
43
+
44
+ # Returns a proxy for calling a stateless service.
45
+ def service(service)
46
+ ClientServiceProxy.new(@ingress_url, resolve_name(service), nil, @ingress_headers)
47
+ end
48
+
49
+ # Returns a proxy for calling a keyed virtual object.
50
+ def object(service, key)
51
+ ClientServiceProxy.new(@ingress_url, resolve_name(service), key, @ingress_headers)
52
+ end
53
+
54
+ # Returns a proxy for calling a workflow.
55
+ def workflow(service, key)
56
+ ClientServiceProxy.new(@ingress_url, resolve_name(service), key, @ingress_headers)
57
+ end
58
+
59
+ # ── Awakeable operations ──
60
+
61
+ # Resolve an awakeable from outside the Restate runtime.
62
+ def resolve_awakeable(awakeable_id, payload)
63
+ post_ingress("/restate/awakeables/#{awakeable_id}/resolve", payload)
64
+ end
65
+
66
+ # Reject an awakeable from outside the Restate runtime.
67
+ def reject_awakeable(awakeable_id, message, code: 500)
68
+ post_ingress("/restate/awakeables/#{awakeable_id}/reject",
69
+ { 'message' => message, 'code' => code })
70
+ end
71
+
72
+ # ── Invocation management ──
73
+
74
+ # Cancel a running invocation.
75
+ def cancel_invocation(invocation_id)
76
+ post_admin("/restate/invocations/#{invocation_id}/cancel", nil)
77
+ end
78
+
79
+ # Kill a running invocation (immediate termination, no cleanup).
80
+ def kill_invocation(invocation_id)
81
+ post_admin("/restate/invocations/#{invocation_id}/kill", nil)
82
+ end
83
+
84
+ private
85
+
86
+ def resolve_name(service)
87
+ if service.is_a?(Class) && service.respond_to?(:service_name)
88
+ service.service_name # steep:ignore NoMethod
89
+ else
90
+ service.to_s
91
+ end
92
+ end
93
+
94
+ def post_ingress(path, body) # rubocop:disable Metrics/AbcSize
95
+ uri = URI("#{@ingress_url}#{path}")
96
+ request = Net::HTTP::Post.new(uri)
97
+ request['Content-Type'] = 'application/json'
98
+ @ingress_headers.each { |k, v| request[k] = v }
99
+ request.body = JSON.generate(body) if body
100
+ response = Net::HTTP.start(uri.hostname, uri.port, # steep:ignore ArgumentTypeMismatch
101
+ use_ssl: uri.scheme == 'https',
102
+ read_timeout: 30) { |http| http.request(request) }
103
+ Kernel.raise "Restate ingress error: #{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
104
+ parse_response(response)
105
+ end
106
+
107
+ def post_admin(path, body) # rubocop:disable Metrics/AbcSize
108
+ uri = URI("#{@admin_url}#{path}")
109
+ request = Net::HTTP::Post.new(uri)
110
+ request['Content-Type'] = 'application/json'
111
+ @admin_headers.each { |k, v| request[k] = v }
112
+ request.body = JSON.generate(body) if body
113
+ response = Net::HTTP.start(uri.hostname, uri.port, # steep:ignore ArgumentTypeMismatch
114
+ use_ssl: uri.scheme == 'https',
115
+ read_timeout: 30) { |http| http.request(request) }
116
+ Kernel.raise "Restate admin error: #{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
117
+ parse_response(response)
118
+ end
119
+
120
+ def parse_response(response)
121
+ body = response.body
122
+ body && !body.empty? ? JSON.parse(body) : nil
123
+ end
124
+ end
125
+
126
+ # Proxy that sends HTTP requests to the Restate ingress for a specific service.
127
+ # Handler calls are forwarded via +method_missing+.
128
+ #
129
+ # @!visibility private
130
+ class ClientServiceProxy
131
+ def initialize(base_url, service_name, key, headers)
132
+ @base_url = base_url
133
+ @service_name = service_name
134
+ @key = key
135
+ @headers = headers
136
+ end
137
+
138
+ def method_missing(handler_name, arg = nil) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength
139
+ path = @key ? "/#{@service_name}/#{@key}/#{handler_name}" : "/#{@service_name}/#{handler_name}"
140
+ uri = URI("#{@base_url}#{path}")
141
+ request = Net::HTTP::Post.new(uri)
142
+ request['Content-Type'] = 'application/json'
143
+ @headers.each { |k, v| request[k] = v }
144
+ request.body = JSON.generate(arg)
145
+ response = Net::HTTP.start(uri.hostname, uri.port, # steep:ignore ArgumentTypeMismatch
146
+ use_ssl: uri.scheme == 'https',
147
+ read_timeout: 30) { |http| http.request(request) }
148
+ Kernel.raise "Restate ingress error: #{response.code} #{response.body}" unless response.is_a?(Net::HTTPSuccess)
149
+ body = response.body
150
+ body && !body.empty? ? JSON.parse(body) : nil
151
+ end
152
+
153
+ def respond_to_missing?(_method_name, _include_private = false)
154
+ true
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,35 @@
1
+ # typed: true
2
+ # frozen_string_literal: true
3
+
4
+ module Restate
5
+ # Global SDK configuration. Set via +Restate.configure+.
6
+ #
7
+ # @example
8
+ # Restate.configure do |c|
9
+ # c.ingress_url = "http://localhost:8080"
10
+ # c.admin_url = "http://localhost:9070"
11
+ # end
12
+ #
13
+ # # Then use the pre-configured client:
14
+ # Restate.client.service(Greeter).greet("World")
15
+ class Config
16
+ # Restate ingress URL (for invoking services).
17
+ attr_accessor :ingress_url
18
+
19
+ # Restate admin URL (for deployments, invocation management).
20
+ attr_accessor :admin_url
21
+
22
+ # Default headers sent with every ingress request.
23
+ attr_accessor :ingress_headers
24
+
25
+ # Default headers sent with every admin request.
26
+ attr_accessor :admin_headers
27
+
28
+ def initialize
29
+ @ingress_url = 'http://localhost:8080'
30
+ @admin_url = 'http://localhost:9070'
31
+ @ingress_headers = {}
32
+ @admin_headers = {}
33
+ end
34
+ end
35
+ end
@@ -1,7 +1,7 @@
1
- # typed: true
1
+ # typed: false
2
2
  # frozen_string_literal: true
3
3
 
4
- # rubocop:disable Metrics/ModuleLength,Metrics/ParameterLists,Style/EmptyMethod
4
+ # rubocop:disable Style/EmptyMethod
5
5
  module Restate
6
6
  # Signals when the current invocation attempt has finished — either the handler
7
7
  # completed, the connection was lost, or a transient error occurred.
@@ -17,27 +17,22 @@ module Restate
17
17
  # # poll event.set? periodically, or pass it to your HTTP client
18
18
  # end
19
19
  class AttemptFinishedEvent
20
- extend T::Sig
21
-
22
- sig { void }
23
20
  def initialize
24
- @mutex = T.let(Mutex.new, Mutex)
25
- @set = T.let(false, T::Boolean)
26
- @waiters = T.let([], T::Array[Thread::Queue])
21
+ @mutex = Mutex.new
22
+ @set = false
23
+ @waiters = []
27
24
  end
28
25
 
29
26
  # Returns true if the attempt has finished.
30
- sig { returns(T::Boolean) }
31
27
  def set?
32
28
  @set
33
29
  end
34
30
 
35
31
  # Blocks the current fiber/thread until the attempt finishes.
36
- sig { void }
37
32
  def wait
38
33
  return if @set
39
34
 
40
- waiter = T.let(nil, T.nilable(Thread::Queue))
35
+ waiter = nil
41
36
  @mutex.synchronize do
42
37
  unless @set
43
38
  waiter = Thread::Queue.new
@@ -49,7 +44,6 @@ module Restate
49
44
 
50
45
  # Marks the event as set and wakes all waiters.
51
46
  # Called internally by the SDK when the attempt ends.
52
- sig { void }
53
47
  def set!
54
48
  @mutex.synchronize do
55
49
  @set = true
@@ -79,258 +73,149 @@ module Restate
79
73
  # @see ObjectContext for VirtualObject handlers (adds state operations)
80
74
  # @see WorkflowContext for Workflow handlers (adds promise operations)
81
75
  module Context
82
- extend T::Sig
83
- extend T::Helpers
84
-
85
- abstract!
86
-
87
76
  # Execute a durable side effect. The block runs at most once; the result
88
77
  # is journaled and replayed on retries.
89
78
  #
90
79
  # Pass +background: true+ to offload the block to a real OS Thread,
91
80
  # keeping the fiber event loop responsive for CPU-intensive work.
92
- sig do
93
- abstract.params(
94
- name: String, serde: T.untyped, retry_policy: T.nilable(RunRetryPolicy),
95
- background: T::Boolean, action: T.proc.returns(T.untyped)
96
- ).returns(DurableFuture)
97
- end
98
81
  def run(name, serde: JsonSerde, retry_policy: nil, background: false, &action); end
99
82
 
100
83
  # Convenience shortcut for +run(...).await+. Returns the result directly.
101
84
  # Accepts all the same options as +run+, including +background: true+.
102
- sig do
103
- abstract.params(
104
- name: String, serde: T.untyped, retry_policy: T.nilable(RunRetryPolicy),
105
- background: T::Boolean, action: T.proc.returns(T.untyped)
106
- ).returns(T.untyped)
107
- end
108
85
  def run_sync(name, serde: JsonSerde, retry_policy: nil, background: false, &action); end
109
86
 
110
87
  # Durable timer that survives handler restarts.
111
- sig { params(seconds: Numeric).returns(DurableFuture) }
112
88
  def sleep(seconds) # rubocop:disable Lint/UnusedMethodArgument
113
89
  Kernel.raise NotImplementedError
114
90
  end
115
91
 
116
92
  # Durably call a handler on a Restate service.
117
- sig do
118
- abstract.params(
119
- service: T.any(String, T::Class[T.anything]), handler: T.any(String, Symbol),
120
- arg: T.untyped, key: T.nilable(String), idempotency_key: T.nilable(String),
121
- headers: T.nilable(T::Hash[String, String]), input_serde: T.untyped, output_serde: T.untyped
122
- ).returns(DurableCallFuture)
123
- end
124
93
  def service_call(service, handler, arg, key: nil, idempotency_key: nil, headers: nil,
125
94
  input_serde: NOT_SET, output_serde: NOT_SET)
126
95
  end
96
+
127
97
  # Fire-and-forget send to a Restate service handler.
128
- sig do
129
- abstract.params(
130
- service: T.any(String, T::Class[T.anything]), handler: T.any(String, Symbol),
131
- arg: T.untyped, key: T.nilable(String), delay: T.nilable(Numeric),
132
- idempotency_key: T.nilable(String), headers: T.nilable(T::Hash[String, String]),
133
- input_serde: T.untyped
134
- ).returns(SendHandle)
135
- end
136
98
  def service_send(service, handler, arg, key: nil, delay: nil, idempotency_key: nil,
137
99
  headers: nil, input_serde: NOT_SET)
138
100
  end
101
+
139
102
  # Durably call a handler on a Restate virtual object.
140
- sig do
141
- abstract.params(
142
- service: T.any(String, T::Class[T.anything]), handler: T.any(String, Symbol),
143
- key: String, arg: T.untyped, idempotency_key: T.nilable(String),
144
- headers: T.nilable(T::Hash[String, String]), input_serde: T.untyped, output_serde: T.untyped
145
- ).returns(DurableCallFuture)
146
- end
147
103
  def object_call(service, handler, key, arg, idempotency_key: nil, headers: nil,
148
104
  input_serde: NOT_SET, output_serde: NOT_SET)
149
105
  end
106
+
150
107
  # Fire-and-forget send to a Restate virtual object handler.
151
- sig do
152
- abstract.params(
153
- service: T.any(String, T::Class[T.anything]), handler: T.any(String, Symbol),
154
- key: String, arg: T.untyped, delay: T.nilable(Numeric),
155
- idempotency_key: T.nilable(String), headers: T.nilable(T::Hash[String, String]),
156
- input_serde: T.untyped
157
- ).returns(SendHandle)
158
- end
159
108
  def object_send(service, handler, key, arg, delay: nil, idempotency_key: nil,
160
109
  headers: nil, input_serde: NOT_SET)
161
110
  end
111
+
162
112
  # Durably call a handler on a Restate workflow.
163
- sig do
164
- abstract.params(
165
- service: T.any(String, T::Class[T.anything]), handler: T.any(String, Symbol),
166
- key: String, arg: T.untyped, idempotency_key: T.nilable(String),
167
- headers: T.nilable(T::Hash[String, String]), input_serde: T.untyped, output_serde: T.untyped
168
- ).returns(DurableCallFuture)
169
- end
170
113
  def workflow_call(service, handler, key, arg, idempotency_key: nil, headers: nil,
171
114
  input_serde: NOT_SET, output_serde: NOT_SET)
172
115
  end
116
+
173
117
  # Fire-and-forget send to a Restate workflow handler.
174
- sig do
175
- abstract.params(
176
- service: T.any(String, T::Class[T.anything]), handler: T.any(String, Symbol),
177
- key: String, arg: T.untyped, delay: T.nilable(Numeric),
178
- idempotency_key: T.nilable(String), headers: T.nilable(T::Hash[String, String]),
179
- input_serde: T.untyped
180
- ).returns(SendHandle)
181
- end
182
118
  def workflow_send(service, handler, key, arg, delay: nil, idempotency_key: nil,
183
119
  headers: nil, input_serde: NOT_SET)
184
120
  end
121
+
185
122
  # Durably call a handler using raw bytes (no serialization).
186
- sig do
187
- abstract.params(
188
- service: String, handler: String, arg: String,
189
- key: T.nilable(String), idempotency_key: T.nilable(String),
190
- headers: T.nilable(T::Hash[String, String])
191
- ).returns(DurableCallFuture)
192
- end
193
123
  def generic_call(service, handler, arg, key: nil, idempotency_key: nil, headers: nil); end
194
124
 
195
125
  # Fire-and-forget send using raw bytes (no serialization).
196
- sig do
197
- abstract.params(
198
- service: String, handler: String, arg: String,
199
- key: T.nilable(String), delay: T.nilable(Numeric),
200
- idempotency_key: T.nilable(String), headers: T.nilable(T::Hash[String, String])
201
- ).returns(SendHandle)
202
- end
203
126
  def generic_send(service, handler, arg, key: nil, delay: nil, idempotency_key: nil, headers: nil); end
204
127
 
205
128
  # Create an awakeable for external callbacks.
206
129
  # Returns [awakeable_id, DurableFuture].
207
- sig { abstract.params(serde: T.untyped).returns([String, DurableFuture]) }
208
130
  def awakeable(serde: JsonSerde); end
209
131
 
210
132
  # Resolve an awakeable with a success value.
211
- sig { abstract.params(awakeable_id: String, payload: T.untyped, serde: T.untyped).void }
212
133
  def resolve_awakeable(awakeable_id, payload, serde: JsonSerde); end
213
134
 
214
135
  # Reject an awakeable with a terminal failure.
215
- sig { abstract.params(awakeable_id: String, message: String, code: Integer).void }
216
136
  def reject_awakeable(awakeable_id, message, code: 500); end
217
137
 
218
138
  # Request cancellation of another invocation.
219
- sig { abstract.params(invocation_id: String).void }
220
139
  def cancel_invocation(invocation_id); end
221
140
 
222
141
  # Wait until any of the given futures completes.
223
142
  # Returns [completed, remaining].
224
- sig { abstract.params(futures: DurableFuture).returns([T::Array[DurableFuture], T::Array[DurableFuture]]) }
225
143
  def wait_any(*futures); end
226
144
 
227
145
  # Returns metadata about the current invocation.
228
- sig { abstract.returns(Request) }
229
146
  def request; end
230
147
 
231
148
  # Returns the key for this virtual object or workflow invocation.
232
- sig { abstract.returns(String) }
233
149
  def key; end
234
150
  end
235
151
 
236
152
  # Context interface for VirtualObject shared handlers (read-only state).
237
153
  # Extends {Context} with +get+, +state_keys+, and +key+ — but no mutations.
238
154
  module ObjectSharedContext
239
- extend T::Sig
240
- extend T::Helpers
241
-
242
- abstract!
243
155
  include Context
244
156
 
245
157
  # Durably retrieve a state entry. Returns nil if unset.
246
- sig { abstract.params(name: String, serde: T.untyped).returns(T.untyped) }
247
158
  def get(name, serde: JsonSerde); end
248
159
 
249
160
  # Durably retrieve a state entry, returning a DurableFuture instead of blocking.
250
- sig { abstract.params(name: String, serde: T.untyped).returns(DurableFuture) }
251
161
  def get_async(name, serde: JsonSerde); end
252
162
 
253
163
  # List all state entry names.
254
- sig { abstract.returns(T.untyped) }
255
164
  def state_keys; end
256
165
 
257
166
  # List all state entry names, returning a DurableFuture instead of blocking.
258
- sig { abstract.returns(DurableFuture) }
259
167
  def state_keys_async; end
260
168
  end
261
169
 
262
170
  # Context interface for VirtualObject exclusive handlers (full state access).
263
171
  # Extends {ObjectSharedContext} with mutating state operations.
264
172
  module ObjectContext
265
- extend T::Sig
266
- extend T::Helpers
267
-
268
- abstract!
269
173
  include ObjectSharedContext
270
174
 
271
175
  # Durably set a state entry.
272
- sig { abstract.params(name: String, value: T.untyped, serde: T.untyped).void }
273
176
  def set(name, value, serde: JsonSerde); end
274
177
 
275
178
  # Durably remove a single state entry.
276
- sig { abstract.params(name: String).void }
277
179
  def clear(name); end
278
180
 
279
181
  # Durably remove all state entries.
280
- sig { abstract.void }
281
182
  def clear_all; end
282
183
  end
283
184
 
284
185
  # Context interface for Workflow shared handlers (read-only state + promises).
285
186
  # Extends {ObjectSharedContext} with durable promise operations.
286
187
  module WorkflowSharedContext
287
- extend T::Sig
288
- extend T::Helpers
289
-
290
- abstract!
291
188
  include ObjectSharedContext
292
189
 
293
190
  # Get a durable promise value, blocking until resolved.
294
- sig { abstract.params(name: String, serde: T.untyped).returns(T.untyped) }
295
191
  def promise(name, serde: JsonSerde); end
296
192
 
297
193
  # Peek at a durable promise without blocking. Returns nil if not yet resolved.
298
- sig { abstract.params(name: String, serde: T.untyped).returns(T.untyped) }
299
194
  def peek_promise(name, serde: JsonSerde); end
300
195
 
301
196
  # Resolve a durable promise with a value.
302
- sig { abstract.params(name: String, payload: T.untyped, serde: T.untyped).void }
303
197
  def resolve_promise(name, payload, serde: JsonSerde); end
304
198
 
305
199
  # Reject a durable promise with a terminal failure.
306
- sig { abstract.params(name: String, message: String, code: Integer).void }
307
200
  def reject_promise(name, message, code: 500); end
308
201
  end
309
202
 
310
203
  # Context interface for Workflow main handler (full state + promises).
311
204
  # Extends {ObjectContext} with durable promise operations.
312
205
  module WorkflowContext
313
- extend T::Sig
314
- extend T::Helpers
315
-
316
- abstract!
317
206
  include ObjectContext
318
207
 
319
208
  # Get a durable promise value, blocking until resolved.
320
- sig { abstract.params(name: String, serde: T.untyped).returns(T.untyped) }
321
209
  def promise(name, serde: JsonSerde); end
322
210
 
323
211
  # Peek at a durable promise without blocking. Returns nil if not yet resolved.
324
- sig { abstract.params(name: String, serde: T.untyped).returns(T.untyped) }
325
212
  def peek_promise(name, serde: JsonSerde); end
326
213
 
327
214
  # Resolve a durable promise with a value.
328
- sig { abstract.params(name: String, payload: T.untyped, serde: T.untyped).void }
329
215
  def resolve_promise(name, payload, serde: JsonSerde); end
330
216
 
331
217
  # Reject a durable promise with a terminal failure.
332
- sig { abstract.params(name: String, message: String, code: Integer).void }
333
218
  def reject_promise(name, message, code: 500); end
334
219
  end
335
220
  end
336
- # rubocop:enable Metrics/ModuleLength,Metrics/ParameterLists,Style/EmptyMethod
221
+ # rubocop:enable Style/EmptyMethod