mirror of
https://github.com/temporalio/temporal.git
synced 2026-08-30 18:41:49 -07:00
Rename SideEffectTaskExecutor to SideEffectTaskHandler and PureTaskExecutor to PureTaskHandler across the CHASM framework and all library implementations (activity, callback, nexusoperation, scheduler). Merge the separate SideEffectTaskDiscarder interface into SideEffectTaskHandler as a required Discard method. Introduce SideEffectTaskHandlerBase[T] which provides a default Discard returning ErrTaskDiscarded, and PureTaskHandlerBase with an unexported marker method — both must be embedded by implementations. This eliminates HasDiscardHandler() from RegistrableTask and the conditional nil check in ExecuteSideEffectDiscardTask, replacing it with eager validation that rejects pure tasks at the call site. The discard function is now always present on side-effect tasks, simplifying the standby task execution path. Also rename executor source files to tasks files in the callback and nexusoperation packages and update receiver names from `e` to `h` throughout. ## Why? - The split interfaces required duplicate registration but in practice both interfaces were implemented by a single struct. - A base implementation is great for future proofing when more optional methods are added.
125 lines
3.1 KiB
Go
125 lines
3.1 KiB
Go
package nexusoperation
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.temporal.io/api/serviceerror"
|
|
"go.temporal.io/server/chasm"
|
|
"go.temporal.io/server/chasm/lib/nexusoperation/gen/nexusoperationpb/v1"
|
|
"go.temporal.io/server/common/log"
|
|
"go.temporal.io/server/common/metrics"
|
|
"go.uber.org/fx"
|
|
)
|
|
|
|
// OperationTaskHandlerOptions is the fx parameter object for common options supplied to all operation task handlers.
|
|
type OperationTaskHandlerOptions struct {
|
|
fx.In
|
|
|
|
Config *Config
|
|
|
|
MetricsHandler metrics.Handler
|
|
Logger log.Logger
|
|
}
|
|
|
|
type OperationInvocationTaskHandler struct {
|
|
chasm.SideEffectTaskHandlerBase[*nexusoperationpb.InvocationTask]
|
|
config *Config
|
|
|
|
metricsHandler metrics.Handler
|
|
logger log.Logger
|
|
}
|
|
|
|
func NewOperationInvocationTaskHandler(opts OperationTaskHandlerOptions) *OperationInvocationTaskHandler {
|
|
return &OperationInvocationTaskHandler{
|
|
config: opts.Config,
|
|
metricsHandler: opts.MetricsHandler,
|
|
logger: opts.Logger,
|
|
}
|
|
}
|
|
|
|
func (h *OperationInvocationTaskHandler) Validate(
|
|
ctx chasm.Context,
|
|
op *Operation,
|
|
attrs chasm.TaskAttributes,
|
|
task *nexusoperationpb.InvocationTask,
|
|
) (bool, error) {
|
|
return false, serviceerror.NewUnimplemented("unimplemented")
|
|
}
|
|
|
|
func (h *OperationInvocationTaskHandler) Execute(
|
|
ctx context.Context,
|
|
opRef chasm.ComponentRef,
|
|
attrs chasm.TaskAttributes,
|
|
task *nexusoperationpb.InvocationTask,
|
|
) error {
|
|
return serviceerror.NewUnimplemented("unimplemented")
|
|
}
|
|
|
|
type OperationBackoffTaskHandler struct {
|
|
chasm.PureTaskHandlerBase
|
|
config *Config
|
|
|
|
metricsHandler metrics.Handler
|
|
logger log.Logger
|
|
}
|
|
|
|
func NewOperationBackoffTaskHandler(opts OperationTaskHandlerOptions) *OperationBackoffTaskHandler {
|
|
return &OperationBackoffTaskHandler{
|
|
config: opts.Config,
|
|
metricsHandler: opts.MetricsHandler,
|
|
logger: opts.Logger,
|
|
}
|
|
}
|
|
|
|
func (h *OperationBackoffTaskHandler) Validate(
|
|
ctx chasm.Context,
|
|
op *Operation,
|
|
attrs chasm.TaskAttributes,
|
|
task *nexusoperationpb.InvocationBackoffTask,
|
|
) (bool, error) {
|
|
return false, serviceerror.NewUnimplemented("unimplemented")
|
|
}
|
|
|
|
func (h *OperationBackoffTaskHandler) Execute(
|
|
ctx chasm.MutableContext,
|
|
op *Operation,
|
|
attrs chasm.TaskAttributes,
|
|
task *nexusoperationpb.InvocationBackoffTask,
|
|
) error {
|
|
return serviceerror.NewUnimplemented("unimplemented")
|
|
}
|
|
|
|
type OperationTimeoutTaskHandler struct {
|
|
chasm.PureTaskHandlerBase
|
|
config *Config
|
|
|
|
metricsHandler metrics.Handler
|
|
logger log.Logger
|
|
}
|
|
|
|
func NewOperationTimeoutTaskHandler(opts OperationTaskHandlerOptions) *OperationTimeoutTaskHandler {
|
|
return &OperationTimeoutTaskHandler{
|
|
config: opts.Config,
|
|
metricsHandler: opts.MetricsHandler,
|
|
logger: opts.Logger,
|
|
}
|
|
}
|
|
|
|
func (h *OperationTimeoutTaskHandler) Validate(
|
|
ctx chasm.Context,
|
|
op *Operation,
|
|
attrs chasm.TaskAttributes,
|
|
task *nexusoperationpb.InvocationTimeoutTask,
|
|
) (bool, error) {
|
|
return false, serviceerror.NewUnimplemented("unimplemented")
|
|
}
|
|
|
|
func (h *OperationTimeoutTaskHandler) Execute(
|
|
ctx chasm.MutableContext,
|
|
op *Operation,
|
|
attrs chasm.TaskAttributes,
|
|
task *nexusoperationpb.InvocationTimeoutTask,
|
|
) error {
|
|
return serviceerror.NewUnimplemented("unimplemented")
|
|
}
|