mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? - TaskAttributes is now passed to all CHASM executors and validators. I decided against introducing a struct for task arguments because it's likely that any additional bits we'd pass along to handlers would go in `TaskAttributes`, and not some outer container (`taskWithAttributes`), and I'd like handlers that don't need attributes to be able to simply `_` them out. ## How did you test it? - [ ] built - [ ] run locally and tested manually - [x] covered by existing tests - [] added new unit test(s) - [ ] added new functional test(s) --------- Co-authored-by: Stephan Behnke <[email protected]>
30 lines
586 B
Go
30 lines
586 B
Go
//go:generate mockgen -package $GOPACKAGE -source $GOFILE -destination task_mock.go
|
|
|
|
package chasm
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
type (
|
|
TaskAttributes struct {
|
|
ScheduledTime time.Time
|
|
Destination string
|
|
}
|
|
|
|
SideEffectTaskExecutor[C any, T any] interface {
|
|
Execute(context.Context, ComponentRef, TaskAttributes, T) error
|
|
}
|
|
|
|
PureTaskExecutor[C any, T any] interface {
|
|
Execute(MutableContext, C, TaskAttributes, T) error
|
|
}
|
|
|
|
TaskValidator[C any, T any] interface {
|
|
Validate(Context, C, TaskAttributes, T) (bool, error)
|
|
}
|
|
)
|
|
|
|
var TaskScheduledTimeImmediate = time.Time{}
|