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.
19 lines
648 B
Go
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() {}
|