Files
temporal/chasm/task_handler_base.go
Roey Berman b781c57a13 Rename task Executor interfaces to Handler and unify discard into SideEffectTaskHandler (#9655)
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.
2026-03-25 15:42:28 -07:00

19 lines
648 B
Go

package chasm
import "context"
// SideEffectTaskHandlerBase provides a default Discard implementation that returns ErrTaskDiscarded.
// Embed this in side-effect task handler structs to satisfy the SideEffectTaskHandler interface.
type SideEffectTaskHandlerBase[T any] struct{}
func (SideEffectTaskHandlerBase[T]) Discard(_ context.Context, _ ComponentRef, _ TaskAttributes, _ T) error {
return ErrTaskDiscarded
}
func (SideEffectTaskHandlerBase[T]) sideEffectTaskHandler() {}
// PureTaskHandlerBase must be embedded in all pure task handler implementations.
type PureTaskHandlerBase struct{}
func (PureTaskHandlerBase) pureTaskHandler() {}