Pulse supports a two-phase job pattern for complex workflows that need to spawn child tasks and aggregate results.
Jobs track their phase using JobMetadata:
type JobMetadata struct {
Phase string `json:"phase,omitempty"` // "ingest" or "aggregate"
// Other metadata fields as needed
}
if job.Metadata != nil && job.Metadata.Phase == "aggregate" {
// Aggregate phase logic
} else {
// Ingest phase logic (default)
}
Jobs maintain parent-child relationships through:
parent_job_id field in the async_ix_jobs table1. Parent job starts (ingest phase)
↓
2. Creates N child jobs
↓
3. Parent pauses/waits
↓
4. Children complete
↓
5. Parent resumes (aggregate phase)
↓
6. Parent aggregates results
↓
7. Parent completes
No special configuration required. The pattern is implemented through job handler logic and JobMetadata.
Phase recovery during graceful restart:
TestGRACEPhaseRecoveryNoChildTasks - pulse/async/grace_test.go:492TestGRACEPhaseRecoveryWithChildTasks - pulse/async/grace_test.go:542Parent-child job hierarchy:
TestParentJobHierarchy - pulse/async/job_test.go:369TestTASBotParentJobHierarchy - pulse/async/store_test.go:250