22
22
23
23
import nexusrpc .handler
24
24
from nexusrpc .handler import CancelOperationContext , StartOperationContext
25
+ from typing_extensions import Concatenate
25
26
26
27
import temporalio .api .common .v1
27
28
import temporalio .api .enums .v1
28
29
import temporalio .client
29
30
import temporalio .common
30
31
from temporalio .nexus ._token import WorkflowHandle
31
32
from temporalio .types import (
33
+ MethodAsyncNoParam ,
32
34
MethodAsyncSingleParam ,
35
+ MultiParamSpec ,
33
36
ParamType ,
34
37
ReturnType ,
35
38
SelfType ,
@@ -195,8 +198,41 @@ def from_start_operation_context(
195
198
** {f .name : getattr (ctx , f .name ) for f in dataclasses .fields (ctx )},
196
199
)
197
200
201
+ # Overload for no-param workflow
202
+ @overload
203
+ async def start_workflow (
204
+ self ,
205
+ workflow : MethodAsyncNoParam [SelfType , ReturnType ],
206
+ * ,
207
+ id : str ,
208
+ task_queue : Optional [str ] = None ,
209
+ execution_timeout : Optional [timedelta ] = None ,
210
+ run_timeout : Optional [timedelta ] = None ,
211
+ task_timeout : Optional [timedelta ] = None ,
212
+ id_reuse_policy : temporalio .common .WorkflowIDReusePolicy = temporalio .common .WorkflowIDReusePolicy .ALLOW_DUPLICATE ,
213
+ id_conflict_policy : temporalio .common .WorkflowIDConflictPolicy = temporalio .common .WorkflowIDConflictPolicy .UNSPECIFIED ,
214
+ retry_policy : Optional [temporalio .common .RetryPolicy ] = None ,
215
+ cron_schedule : str = "" ,
216
+ memo : Optional [Mapping [str , Any ]] = None ,
217
+ search_attributes : Optional [
218
+ Union [
219
+ temporalio .common .TypedSearchAttributes ,
220
+ temporalio .common .SearchAttributes ,
221
+ ]
222
+ ] = None ,
223
+ static_summary : Optional [str ] = None ,
224
+ static_details : Optional [str ] = None ,
225
+ start_delay : Optional [timedelta ] = None ,
226
+ start_signal : Optional [str ] = None ,
227
+ start_signal_args : Sequence [Any ] = [],
228
+ rpc_metadata : Mapping [str , str ] = {},
229
+ rpc_timeout : Optional [timedelta ] = None ,
230
+ request_eager_start : bool = False ,
231
+ priority : temporalio .common .Priority = temporalio .common .Priority .default ,
232
+ versioning_override : Optional [temporalio .common .VersioningOverride ] = None ,
233
+ ) -> WorkflowHandle [ReturnType ]: ...
234
+
198
235
# Overload for single-param workflow
199
- # TODO(nexus-prerelease)*: bring over other overloads
200
236
@overload
201
237
async def start_workflow (
202
238
self ,
@@ -231,6 +267,43 @@ async def start_workflow(
231
267
versioning_override : Optional [temporalio .common .VersioningOverride ] = None ,
232
268
) -> WorkflowHandle [ReturnType ]: ...
233
269
270
+ # Overload for multi-param workflow
271
+ @overload
272
+ async def start_workflow (
273
+ self ,
274
+ workflow : Callable [
275
+ Concatenate [SelfType , MultiParamSpec ], Awaitable [ReturnType ]
276
+ ],
277
+ * ,
278
+ args : Sequence [Any ],
279
+ id : str ,
280
+ task_queue : Optional [str ] = None ,
281
+ execution_timeout : Optional [timedelta ] = None ,
282
+ run_timeout : Optional [timedelta ] = None ,
283
+ task_timeout : Optional [timedelta ] = None ,
284
+ id_reuse_policy : temporalio .common .WorkflowIDReusePolicy = temporalio .common .WorkflowIDReusePolicy .ALLOW_DUPLICATE ,
285
+ id_conflict_policy : temporalio .common .WorkflowIDConflictPolicy = temporalio .common .WorkflowIDConflictPolicy .UNSPECIFIED ,
286
+ retry_policy : Optional [temporalio .common .RetryPolicy ] = None ,
287
+ cron_schedule : str = "" ,
288
+ memo : Optional [Mapping [str , Any ]] = None ,
289
+ search_attributes : Optional [
290
+ Union [
291
+ temporalio .common .TypedSearchAttributes ,
292
+ temporalio .common .SearchAttributes ,
293
+ ]
294
+ ] = None ,
295
+ static_summary : Optional [str ] = None ,
296
+ static_details : Optional [str ] = None ,
297
+ start_delay : Optional [timedelta ] = None ,
298
+ start_signal : Optional [str ] = None ,
299
+ start_signal_args : Sequence [Any ] = [],
300
+ rpc_metadata : Mapping [str , str ] = {},
301
+ rpc_timeout : Optional [timedelta ] = None ,
302
+ request_eager_start : bool = False ,
303
+ priority : temporalio .common .Priority = temporalio .common .Priority .default ,
304
+ versioning_override : Optional [temporalio .common .VersioningOverride ] = None ,
305
+ ) -> WorkflowHandle [ReturnType ]: ...
306
+
234
307
# Overload for string-name workflow
235
308
@overload
236
309
async def start_workflow (
@@ -241,7 +314,7 @@ async def start_workflow(
241
314
args : Sequence [Any ] = [],
242
315
id : str ,
243
316
task_queue : Optional [str ] = None ,
244
- result_type : Optional [Type ] = None ,
317
+ result_type : Optional [Type [ ReturnType ] ] = None ,
245
318
execution_timeout : Optional [timedelta ] = None ,
246
319
run_timeout : Optional [timedelta ] = None ,
247
320
task_timeout : Optional [timedelta ] = None ,
@@ -266,7 +339,7 @@ async def start_workflow(
266
339
request_eager_start : bool = False ,
267
340
priority : temporalio .common .Priority = temporalio .common .Priority .default ,
268
341
versioning_override : Optional [temporalio .common .VersioningOverride ] = None ,
269
- ) -> WorkflowHandle [Any ]: ...
342
+ ) -> WorkflowHandle [ReturnType ]: ...
270
343
271
344
async def start_workflow (
272
345
self ,
0 commit comments