Files
tasks/chasm/lib/scheduler/scheduler_tasks.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

54 lines
1.2 KiB
Go

package scheduler
import (
"time"
"github.com/hanzoai/tasks/chasm"
"github.com/hanzoai/tasks/chasm/lib/scheduler/gen/schedulerpb/v1"
"go.uber.org/fx"
)
type SchedulerIdleTaskExecutorOptions struct {
fx.In
Config *Config
}
type SchedulerIdleTaskExecutor struct {
config *Config
}
func NewSchedulerIdleTaskExecutor(opts SchedulerIdleTaskExecutorOptions) *SchedulerIdleTaskExecutor {
return &SchedulerIdleTaskExecutor{
config: opts.Config,
}
}
func (r *SchedulerIdleTaskExecutor) Execute(
ctx chasm.MutableContext,
scheduler *Scheduler,
_ chasm.TaskAttributes,
_ *schedulerpb.SchedulerIdleTask,
) error {
scheduler.Closed = true
return nil
}
func (r *SchedulerIdleTaskExecutor) Validate(
ctx chasm.Context,
scheduler *Scheduler,
taskAttrs chasm.TaskAttributes,
task *schedulerpb.SchedulerIdleTask,
) (bool, error) {
idleTimeTotal := task.IdleTimeTotal.AsDuration()
idleExpiration, isIdle := scheduler.getIdleExpiration(ctx, idleTimeTotal, time.Time{})
// If the scheduler has since woken up, or its idle expiration time changed, this
// task must be obsolete.
if !isIdle || idleExpiration.Compare(taskAttrs.ScheduledTime) != 0 {
return false, nil
}
return !scheduler.Closed, nil
}