Skip to content

Commit fc8f5ac

Browse files
committed
Validator generator
1 parent 3654a89 commit fc8f5ac

15 files changed

Lines changed: 1211 additions & 308 deletions

File tree

chasm/lib/nexusoperation/frontend.go

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import (
1010
"go.temporal.io/api/workflowservice/v1"
1111
"go.temporal.io/server/chasm"
1212
nexusoperationpb "go.temporal.io/server/chasm/lib/nexusoperation/gen/nexusoperationpb/v1"
13-
"go.temporal.io/server/common/log"
1413
"go.temporal.io/server/common/namespace"
1514
commonnexus "go.temporal.io/server/common/nexus"
16-
"go.temporal.io/server/common/searchattribute"
15+
"go.temporal.io/server/common/validation"
1716
"google.golang.org/protobuf/types/known/durationpb"
1817
"google.golang.org/protobuf/types/known/emptypb"
1918
"google.golang.org/protobuf/types/known/timestamppb"
@@ -36,30 +35,24 @@ var ErrStandaloneNexusOperationDisabled = serviceerror.NewUnimplemented("Standal
3635
type frontendHandler struct {
3736
client nexusoperationpb.NexusOperationServiceClient
3837
config *Config
39-
logger log.Logger
4038
namespaceRegistry namespace.Registry
4139
endpointRegistry commonnexus.EndpointRegistry
42-
saMapperProvider searchattribute.MapperProvider
43-
saValidator *searchattribute.Validator
40+
validatorRegistry *validation.ValidatorRegistry
4441
}
4542

4643
func NewFrontendHandler(
4744
client nexusoperationpb.NexusOperationServiceClient,
4845
config *Config,
49-
logger log.Logger,
5046
namespaceRegistry namespace.Registry,
5147
endpointRegistry commonnexus.EndpointRegistry,
52-
saMapperProvider searchattribute.MapperProvider,
53-
saValidator *searchattribute.Validator,
48+
validatorRegistry *validation.ValidatorRegistry,
5449
) FrontendHandler {
5550
return &frontendHandler{
5651
client: client,
5752
config: config,
58-
logger: logger,
5953
namespaceRegistry: namespaceRegistry,
6054
endpointRegistry: endpointRegistry,
61-
saMapperProvider: saMapperProvider,
62-
saValidator: saValidator,
55+
validatorRegistry: validatorRegistry,
6356
}
6457
}
6558

@@ -76,7 +69,7 @@ func (h *frontendHandler) StartNexusOperationExecution(
7669
return nil, err
7770
}
7871

79-
if err := validateAndNormalizeStartRequest(req, h.config, h.logger, h.saMapperProvider, h.saValidator); err != nil {
72+
if err := validation.ValidateAndNormalize(h.validatorRegistry, req); err != nil {
8073
return nil, err
8174
}
8275

@@ -107,7 +100,7 @@ func (h *frontendHandler) DescribeNexusOperationExecution(
107100
return nil, err
108101
}
109102

110-
if err := validateAndNormalizeDescribeRequest(req, namespaceID.String(), h.config); err != nil {
103+
if err := newDescribeNexusOperationExecutionRequestValidator(h.config, namespaceID.String()).ValidateAndNormalize(req); err != nil {
111104
return nil, err
112105
}
113106

@@ -127,7 +120,7 @@ func (h *frontendHandler) PollNexusOperationExecution(
127120
return nil, ErrStandaloneNexusOperationDisabled
128121
}
129122

130-
if err := validateAndNormalizePollRequest(req, h.config); err != nil {
123+
if err := validation.ValidateAndNormalize(h.validatorRegistry, req); err != nil {
131124
return nil, err
132125
}
133126

@@ -248,7 +241,7 @@ func (h *frontendHandler) RequestCancelNexusOperationExecution(
248241
return nil, err
249242
}
250243

251-
if err := validateAndNormalizeCancelRequest(req, h.config); err != nil {
244+
if err := validation.ValidateAndNormalize(h.validatorRegistry, req); err != nil {
252245
return nil, err
253246
}
254247

@@ -276,7 +269,7 @@ func (h *frontendHandler) TerminateNexusOperationExecution(
276269
return nil, err
277270
}
278271

279-
if err := validateAndNormalizeTerminateRequest(req, h.config); err != nil {
272+
if err := validation.ValidateAndNormalize(h.validatorRegistry, req); err != nil {
280273
return nil, err
281274
}
282275

@@ -304,7 +297,7 @@ func (h *frontendHandler) DeleteNexusOperationExecution(
304297
return nil, err
305298
}
306299

307-
if err := validateAndNormalizeDeleteRequest(req, h.config); err != nil {
300+
if err := validation.ValidateAndNormalize(h.validatorRegistry, req); err != nil {
308301
return nil, err
309302
}
310303

chasm/lib/nexusoperation/fx.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"go.temporal.io/api/serviceerror"
99
persistencespb "go.temporal.io/server/api/persistence/v1"
1010
"go.temporal.io/server/chasm"
11-
nexusoperationpb "go.temporal.io/server/chasm/lib/nexusoperation/gen/nexusoperationpb/v1"
1211
"go.temporal.io/server/common"
1312
"go.temporal.io/server/common/cluster"
1413
"go.temporal.io/server/common/collection"
@@ -47,15 +46,7 @@ var Module = fx.Module(
4746

4847
var FrontendModule = fx.Module(
4948
"chasm.lib.nexusoperation.frontend",
50-
fx.Provide(configProvider),
51-
fx.Provide(nexusoperationpb.NewNexusOperationServiceLayeredClient),
52-
fx.Provide(NewFrontendHandler),
53-
fx.Provide(newComponentOnlyLibrary),
54-
fx.Invoke(func(l *componentOnlyLibrary, registry *chasm.Registry) error {
55-
// Frontend needs to register the component in order to serialize ComponentRefs, but doesn't
56-
// need task handlers.
57-
return registry.Register(l)
58-
}),
49+
ValidatorModule,
5950
)
6051

6152
func register(

0 commit comments

Comments
 (0)