@@ -120,97 +120,123 @@ impl WorkerClientBag {
120
120
/// minimal mocking surface. Delegates to [WorkflowClientTrait] so see that for details.
121
121
#[ cfg_attr( test, mockall:: automock) ]
122
122
#[ async_trait:: async_trait]
123
- pub ( crate ) trait WorkerClient : Sync + Send {
123
+ pub trait WorkerClient : Sync + Send {
124
+ /// Poll workflow tasks
124
125
async fn poll_workflow_task (
125
126
& self ,
126
127
poll_options : PollOptions ,
127
128
wf_options : PollWorkflowOptions ,
128
129
) -> Result < PollWorkflowTaskQueueResponse > ;
130
+ /// Poll activity tasks
129
131
async fn poll_activity_task (
130
132
& self ,
131
133
poll_options : PollOptions ,
132
134
act_options : PollActivityOptions ,
133
135
) -> Result < PollActivityTaskQueueResponse > ;
136
+ /// Poll Nexus tasks
134
137
async fn poll_nexus_task (
135
138
& self ,
136
139
poll_options : PollOptions ,
137
140
) -> Result < PollNexusTaskQueueResponse > ;
141
+ /// Complete a workflow task
138
142
async fn complete_workflow_task (
139
143
& self ,
140
144
request : WorkflowTaskCompletion ,
141
145
) -> Result < RespondWorkflowTaskCompletedResponse > ;
146
+ /// Complete an activity task
142
147
async fn complete_activity_task (
143
148
& self ,
144
149
task_token : TaskToken ,
145
150
result : Option < Payloads > ,
146
151
) -> Result < RespondActivityTaskCompletedResponse > ;
152
+ /// Complete a Nexus task
147
153
async fn complete_nexus_task (
148
154
& self ,
149
155
task_token : TaskToken ,
150
156
response : nexus:: v1:: Response ,
151
157
) -> Result < RespondNexusTaskCompletedResponse > ;
158
+ /// Record an activity heartbeat
152
159
async fn record_activity_heartbeat (
153
160
& self ,
154
161
task_token : TaskToken ,
155
162
details : Option < Payloads > ,
156
163
) -> Result < RecordActivityTaskHeartbeatResponse > ;
164
+ /// Cancel an activity task
157
165
async fn cancel_activity_task (
158
166
& self ,
159
167
task_token : TaskToken ,
160
168
details : Option < Payloads > ,
161
169
) -> Result < RespondActivityTaskCanceledResponse > ;
170
+ /// Fail an activity task
162
171
async fn fail_activity_task (
163
172
& self ,
164
173
task_token : TaskToken ,
165
174
failure : Option < Failure > ,
166
175
) -> Result < RespondActivityTaskFailedResponse > ;
176
+ /// Fail a workflow task
167
177
async fn fail_workflow_task (
168
178
& self ,
169
179
task_token : TaskToken ,
170
180
cause : WorkflowTaskFailedCause ,
171
181
failure : Option < Failure > ,
172
182
) -> Result < RespondWorkflowTaskFailedResponse > ;
183
+ /// Fail a Nexus task
173
184
async fn fail_nexus_task (
174
185
& self ,
175
186
task_token : TaskToken ,
176
187
error : nexus:: v1:: HandlerError ,
177
188
) -> Result < RespondNexusTaskFailedResponse > ;
189
+ /// Get the workflow execution history
178
190
async fn get_workflow_execution_history (
179
191
& self ,
180
192
workflow_id : String ,
181
193
run_id : Option < String > ,
182
194
page_token : Vec < u8 > ,
183
195
) -> Result < GetWorkflowExecutionHistoryResponse > ;
196
+ /// Respond to a legacy query
184
197
async fn respond_legacy_query (
185
198
& self ,
186
199
task_token : TaskToken ,
187
200
query_result : QueryResult ,
188
201
) -> Result < RespondQueryTaskCompletedResponse > ;
202
+ /// Describe the namespace
189
203
async fn describe_namespace ( & self ) -> Result < DescribeNamespaceResponse > ;
204
+ /// Shutdown the worker
190
205
async fn shutdown_worker ( & self , sticky_task_queue : String ) -> Result < ShutdownWorkerResponse > ;
191
206
207
+ /// Replace the underlying client
192
208
fn replace_client ( & self , new_client : RetryClient < Client > ) ;
209
+ /// Return server capabilities
193
210
fn capabilities ( & self ) -> Option < Capabilities > ;
211
+ /// Return workers using this client
194
212
fn workers ( & self ) -> Arc < SlotManager > ;
213
+ /// Indicates if this is a mock client
195
214
fn is_mock ( & self ) -> bool ;
196
- /// Return (sdk_name, sdk_version) from the underlying client configuration
215
+ /// Return name and version of the SDK
197
216
fn sdk_name_and_version ( & self ) -> ( String , String ) ;
198
217
}
199
218
219
+ /// Configuration options shared by workflow, activity, and Nexus polling calls
200
220
#[ derive( Debug , Clone ) ]
201
- pub ( crate ) struct PollOptions {
202
- pub ( crate ) task_queue : String ,
203
- pub ( crate ) no_retry : Option < NoRetryOnMatching > ,
204
- pub ( crate ) timeout_override : Option < Duration > ,
221
+ pub struct PollOptions {
222
+ /// The name of the task queue to poll
223
+ pub task_queue : String ,
224
+ /// Prevents retrying on specific gRPC statuses
225
+ pub no_retry : Option < NoRetryOnMatching > ,
226
+ /// Overrides the default RPC timeout for the poll request
227
+ pub timeout_override : Option < Duration > ,
205
228
}
229
+ /// Additional options specific to workflow task polling
206
230
#[ derive( Debug , Clone ) ]
207
- pub ( crate ) struct PollWorkflowOptions {
208
- // If true this will be a sticky poll
209
- pub ( crate ) sticky_queue_name : Option < String > ,
231
+ pub struct PollWorkflowOptions {
232
+ /// Optional sticky queue name for session‐based workflow polling
233
+ pub sticky_queue_name : Option < String > ,
210
234
}
235
+ /// Additional options specific to activity task polling
211
236
#[ derive( Debug , Clone ) ]
212
- pub ( crate ) struct PollActivityOptions {
213
- pub ( crate ) max_tasks_per_sec : Option < f64 > ,
237
+ pub struct PollActivityOptions {
238
+ /// Optional rate limit (tasks per second) for activity polling
239
+ pub max_tasks_per_sec : Option < f64 > ,
214
240
}
215
241
216
242
#[ async_trait:: async_trait]
@@ -634,25 +660,25 @@ impl NamespacedClient for WorkerClientBag {
634
660
/// A version of [RespondWorkflowTaskCompletedRequest] that will finish being filled out by the
635
661
/// server client
636
662
#[ derive( Debug , Clone , PartialEq ) ]
637
- pub ( crate ) struct WorkflowTaskCompletion {
663
+ pub struct WorkflowTaskCompletion {
638
664
/// The task token that would've been received from polling for a workflow activation
639
- pub ( crate ) task_token : TaskToken ,
665
+ pub task_token : TaskToken ,
640
666
/// A list of new commands to send to the server, such as starting a timer.
641
- pub ( crate ) commands : Vec < Command > ,
667
+ pub commands : Vec < Command > ,
642
668
/// A list of protocol messages to send to the server.
643
- pub ( crate ) messages : Vec < ProtocolMessage > ,
669
+ pub messages : Vec < ProtocolMessage > ,
644
670
/// If set, indicate that next task should be queued on sticky queue with given attributes.
645
- pub ( crate ) sticky_attributes : Option < StickyExecutionAttributes > ,
671
+ pub sticky_attributes : Option < StickyExecutionAttributes > ,
646
672
/// Responses to queries in the `queries` field of the workflow task.
647
- pub ( crate ) query_responses : Vec < QueryResult > ,
673
+ pub query_responses : Vec < QueryResult > ,
648
674
/// Indicate that the task completion should return a new WFT if one is available
649
- pub ( crate ) return_new_workflow_task : bool ,
675
+ pub return_new_workflow_task : bool ,
650
676
/// Force a new WFT to be created after this completion
651
- pub ( crate ) force_create_new_workflow_task : bool ,
677
+ pub force_create_new_workflow_task : bool ,
652
678
/// SDK-specific metadata to send
653
- pub ( crate ) sdk_metadata : WorkflowTaskCompletedMetadata ,
679
+ pub sdk_metadata : WorkflowTaskCompletedMetadata ,
654
680
/// Metering info
655
- pub ( crate ) metering_metadata : MeteringMetadata ,
681
+ pub metering_metadata : MeteringMetadata ,
656
682
/// Versioning behavior of the workflow, if any.
657
- pub ( crate ) versioning_behavior : VersioningBehavior ,
683
+ pub versioning_behavior : VersioningBehavior ,
658
684
}
0 commit comments