Skip to content

Commit 2f7e5d1

Browse files
committed
Nexus Standalone: Poll
1 parent c6a4fe7 commit 2f7e5d1

File tree

17 files changed

+1006
-54
lines changed

17 files changed

+1006
-54
lines changed

chasm/lib/nexusoperation/config.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ import (
1010
"go.temporal.io/server/common/rpc/interceptor"
1111
)
1212

13+
var LongPollTimeout = dynamicconfig.NewNamespaceDurationSetting(
14+
"nexusoperation.longPollTimeout",
15+
20*time.Second,
16+
`Timeout for nexus operation long-poll requests.`,
17+
)
18+
19+
var LongPollBuffer = dynamicconfig.NewNamespaceDurationSetting(
20+
"nexusoperation.longPollBuffer",
21+
time.Second,
22+
`A buffer used to adjust the nexus operation long-poll timeouts.
23+
Specifically, nexus operation long-poll requests are timed out at a time which leaves at least the buffer's duration
24+
remaining before the caller's deadline, if permitted by the caller's deadline.`,
25+
)
26+
1327
var Enabled = dynamicconfig.NewNamespaceBoolSetting(
1428
"nexusoperation.enableStandalone",
1529
false,
@@ -165,6 +179,8 @@ type Config struct {
165179
Enabled dynamicconfig.BoolPropertyFnWithNamespaceFilter
166180
ChasmEnabled dynamicconfig.BoolPropertyFnWithNamespaceFilter
167181
ChasmNexusEnabled dynamicconfig.BoolPropertyFnWithNamespaceFilter
182+
LongPollBuffer dynamicconfig.DurationPropertyFnWithNamespaceFilter
183+
LongPollTimeout dynamicconfig.DurationPropertyFnWithNamespaceFilter
168184
RequestTimeout dynamicconfig.DurationPropertyFnWithDestinationFilter
169185
MinRequestTimeout dynamicconfig.DurationPropertyFnWithNamespaceFilter
170186
MaxConcurrentOperations dynamicconfig.IntPropertyFnWithNamespaceFilter
@@ -190,6 +206,8 @@ func configProvider(dc *dynamicconfig.Collection) *Config {
190206
Enabled: Enabled.Get(dc),
191207
ChasmEnabled: dynamicconfig.EnableChasm.Get(dc),
192208
ChasmNexusEnabled: ChasmNexusEnabled.Get(dc),
209+
LongPollBuffer: LongPollBuffer.Get(dc),
210+
LongPollTimeout: LongPollTimeout.Get(dc),
193211
RequestTimeout: RequestTimeout.Get(dc),
194212
MinRequestTimeout: MinRequestTimeout.Get(dc),
195213
MaxConcurrentOperations: MaxConcurrentOperations.Get(dc),

chasm/lib/nexusoperation/frontend.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,29 @@ func (h *frontendHandler) DescribeNexusOperationExecution(
121121
return resp.GetFrontendResponse(), err
122122
}
123123

124-
func (h *frontendHandler) PollNexusOperationExecution(_ context.Context, req *workflowservice.PollNexusOperationExecutionRequest) (*workflowservice.PollNexusOperationExecutionResponse, error) {
124+
// PollNexusOperationExecution long-polls for a Nexus operation to reach a specific stage.
125+
func (h *frontendHandler) PollNexusOperationExecution(
126+
ctx context.Context,
127+
req *workflowservice.PollNexusOperationExecutionRequest,
128+
) (*workflowservice.PollNexusOperationExecutionResponse, error) {
125129
if !h.isStandaloneNexusOperationEnabled(req.GetNamespace()) {
126130
return nil, ErrStandaloneNexusOperationDisabled
127131
}
128-
return nil, serviceerror.NewUnimplemented("PollNexusOperationExecution not implemented")
132+
133+
if err := validateAndNormalizePollRequest(req, h.config); err != nil {
134+
return nil, err
135+
}
136+
137+
namespaceID, err := h.namespaceRegistry.GetNamespaceID(namespace.Name(req.GetNamespace()))
138+
if err != nil {
139+
return nil, err
140+
}
141+
142+
resp, err := h.client.PollNexusOperation(ctx, &nexusoperationpb.PollNexusOperationRequest{
143+
NamespaceId: namespaceID.String(),
144+
FrontendRequest: req,
145+
})
146+
return resp.GetFrontendResponse(), err
129147
}
130148

131149
func (h *frontendHandler) ListNexusOperationExecutions(

chasm/lib/nexusoperation/gen/nexusoperationpb/v1/request_response.go-helpers.pb.go

Lines changed: 74 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

chasm/lib/nexusoperation/gen/nexusoperationpb/v1/request_response.pb.go

Lines changed: 129 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)