36
36
# CancelOperationContext and passes it as the first parameter to the nexusrpc operation
37
37
# handler. In addition, it sets one of the following context vars.
38
38
39
- _temporal_start_operation_context : ContextVar [TemporalStartOperationContext ] = (
39
+ _temporal_start_operation_context : ContextVar [_TemporalStartOperationContext ] = (
40
40
ContextVar ("temporal-start-operation-context" )
41
41
)
42
42
@@ -71,7 +71,7 @@ def client() -> temporalio.client.Client:
71
71
72
72
73
73
def _temporal_context () -> (
74
- Union [TemporalStartOperationContext , _TemporalCancelOperationContext ]
74
+ Union [_TemporalStartOperationContext , _TemporalCancelOperationContext ]
75
75
):
76
76
ctx = _try_temporal_context ()
77
77
if ctx is None :
@@ -80,7 +80,7 @@ def _temporal_context() -> (
80
80
81
81
82
82
def _try_temporal_context () -> (
83
- Optional [Union [TemporalStartOperationContext , _TemporalCancelOperationContext ]]
83
+ Optional [Union [_TemporalStartOperationContext , _TemporalCancelOperationContext ]]
84
84
):
85
85
start_ctx = _temporal_start_operation_context .get (None )
86
86
cancel_ctx = _temporal_cancel_operation_context .get (None )
@@ -90,7 +90,7 @@ def _try_temporal_context() -> (
90
90
91
91
92
92
@dataclass
93
- class TemporalStartOperationContext :
93
+ class _TemporalStartOperationContext :
94
94
"""
95
95
Context for a Nexus start operation being handled by a Temporal Nexus Worker.
96
96
"""
@@ -105,7 +105,7 @@ class TemporalStartOperationContext:
105
105
"""The Temporal client in use by the worker handling this Nexus operation."""
106
106
107
107
@classmethod
108
- def get (cls ) -> TemporalStartOperationContext :
108
+ def get (cls ) -> _TemporalStartOperationContext :
109
109
ctx = _temporal_start_operation_context .get (None )
110
110
if ctx is None :
111
111
raise RuntimeError ("Not in Nexus operation context." )
@@ -171,10 +171,10 @@ def add_outbound_links(
171
171
172
172
@dataclass (frozen = True )
173
173
class WorkflowRunOperationContext (StartOperationContext ):
174
- _temporal_context : Optional [TemporalStartOperationContext ] = None
174
+ _temporal_context : Optional [_TemporalStartOperationContext ] = None
175
175
176
176
@property
177
- def temporal_context (self ) -> TemporalStartOperationContext :
177
+ def temporal_context (self ) -> _TemporalStartOperationContext :
178
178
if not self ._temporal_context :
179
179
raise RuntimeError ("Temporal context not set" )
180
180
return self ._temporal_context
@@ -188,7 +188,7 @@ def from_start_operation_context(
188
188
cls , ctx : StartOperationContext
189
189
) -> WorkflowRunOperationContext :
190
190
return cls (
191
- _temporal_context = TemporalStartOperationContext .get (),
191
+ _temporal_context = _TemporalStartOperationContext .get (),
192
192
** {f .name : getattr (ctx , f .name ) for f in dataclasses .fields (ctx )},
193
193
)
194
194
0 commit comments