Skip to content

feat(temporal/job): add type-focused workflow Definition layer#58

Merged
jasoet merged 10 commits into
mainfrom
feat/temporal-job
May 11, 2026
Merged

feat(temporal/job): add type-focused workflow Definition layer#58
jasoet merged 10 commits into
mainfrom
feat/temporal-job

Conversation

@jasoet
Copy link
Copy Markdown
Owner

@jasoet jasoet commented May 10, 2026

Summary

Adds pkg/temporal/job — a generic, transport-agnostic abstraction for one registered Temporal workflow. Every per-job operation hangs off *job.Definition as a method: register, execute, describe, history, cancel, terminate, signal, query, schedule lifecycle, list runs, stats.

The new package coexists with existing pkg/temporal managers — WorkflowManager/ScheduleManager handle namespace-wide ops; Definition is the per-job lens.

What's new

  • job.Definition + job.New(name, taskQueue, opts...) functional-options constructor
  • job.Registry for name → Definition lookup + RegisterAll/ApplySchedules
  • job.RegisterWorkflowOnce / RegisterActivityOnce — idempotent worker registration for cases where multiple Definitions share a workflow type
  • job.ScheduleSpec with interval / cron / calendar support + overlap policy
  • Typed Status, ActivityStatus, RunDetail, RunHistory, RunPage, ScheduleDetail, etc.
  • SDK error translation (ErrNotFound, etc.) preserving the underlying error chain
  • Workflow ID convention: `<Name>-<uuid>` with caller override via `WithWorkflowID`
  • `ListRuns` / `Stats` automatically scope visibility queries by the Name prefix

Spec

go-wf docs/superpowers/specs/2026-05-11-pkg-temporal-job-definition-design.md

Test plan

  • Unit tests pass (`go test ./temporal/job/...`) — 27 tests, all green
  • Integration tests pass against real Temporal container (`task test:integration`) — 5 new `TestIntegration_*` tests pass; existing `pkg/v2/db` and `pkg/v2/ssh` failures are pre-existing on `main` and unrelated
  • `task lint` clean

jasoet added 10 commits May 11, 2026 05:59
Introduces ListOpts, StatsOpts, HistoryOpts, ScheduleListOpts, and
ExecuteOption (with builders) for configuring Definition operations.
Adds sentinel errors and translateSDKError for typed SDK error wrapping.
…GetRun

Implements Task 5: Definition struct with option-based constructor (New),
Register, Execute, GetRun methods, and RegisterWorkflowOnce/RegisterActivityOnce
dedup helpers backed by sync.Map.
Implements Registry with Add, Get, MustGet, List, Names, RegisterAll,
and a stub ApplySchedules pending Task 8.
…tats

Add per-run workflow operations on Definition: Describe, History, Cancel,
Terminate, Signal, Query, ListRuns, and Stats. All delegate to the Temporal
client and share the scoped visibility-query helper (WorkflowId STARTS_WITH).
Implement Definition.ApplySchedule (create-or-update), PauseSchedule,
ResumeSchedule, TriggerSchedule, DeleteSchedule, and DescribeSchedule.
Replace the ApplySchedules stub in Registry with the real implementation.
Five integration tests cover full Definition lifecycle (execute, describe,
history, cancel, list), schedule lifecycle (apply, describe, pause, resume,
trigger, delete), and Registry deduplication across shared workflow types.
@jasoet jasoet force-pushed the feat/temporal-job branch from 69b0247 to b593fef Compare May 10, 2026 23:32
@jasoet jasoet merged commit f8ae822 into main May 11, 2026
1 check passed
@jasoet jasoet deleted the feat/temporal-job branch May 11, 2026 02:30
jasoet added a commit to jasoet/go-wf that referenced this pull request May 11, 2026
Consume the new pkg/temporal/job package and converge all four go-wf builders on producing *job.Definition.

- container.RegisterAll / function.RegisterAll made idempotent via job.RegisterWorkflowOnce / RegisterActivityOnce
- datasync builder: Build() returns *job.Definition; FullJobRegistration deleted
- datasync/chunk: Build() returns *job.Definition; new ScheduleEvery / ScheduleCron / ScheduleRaw setters replace Schedule(d)
- function builder: single Build() returning *job.Definition; mode via .Pipeline()/.Parallel()/.Single()/.Loop()/.ParameterizedLoop()
- container builder: same convergence; mode via .Pipeline()/.Parallel()/.Single()/.Loop()/.ParameterizedLoop()
- 15 example files updated for new pkg/v2 NewClient signature and *job.Definition API

Spec: docs/superpowers/specs/2026-05-11-pkg-temporal-job-definition-design.md
Depends on: jasoet/pkg#58 (merged)
PR: #20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant