feat: converge builders on *job.Definition (pkg/temporal/job consumer)#20
Merged
Conversation
…flowOnce Route all workflow and activity registrations through job.RegisterWorkflowOnce / job.RegisterActivityOnce so that calling RegisterAll (or RegisterWorkflows / RegisterActivities) more than once on the same worker becomes a silent no-op instead of panicking with "duplicate workflow type". Add TestRegisterAll_Idempotent to verify the dedup mechanic end-to-end using the mock worker.
…lowOnce Route all workflow and activity registrations through job.RegisterWorkflowOnce and job.RegisterActivityOnce so that calling RegisterWorkflows, RegisterActivity, or RegisterAll multiple times on the same worker is a no-op after the first call. Change function signatures from the narrow WorkflowRegistrar interface to worker.Worker (matching the container package pattern). Update worker_test.go to use a mockWorker and add TestRegisterAll_Idempotent to verify dedup behaviour.
Replace datasync/builder Build() and datasync/chunk Build() return types from datasync.Job[T,U]/FullJobRegistration to *job.Definition, and remove the FullJobRegistration struct and BuildJobRegistration function from datasync/workflow/sync.go. Update all test assertions accordingly.
Replace the single Schedule(time.Duration) setter on ChunkedSync and DateChunkedSync with three typed setters: ScheduleEvery (interval), ScheduleCron (cron expression), and ScheduleRaw (*job.ScheduleSpec). The internal schedule field is now *job.ScheduleSpec directly, so Build() passes it through without wrapping.
…eline()/.Parallel()/.Single() WorkflowBuilder and LoopBuilder now expose Build() (*job.Definition, error) as the primary entry point. Mode is selected via fluent setters (.Pipeline(), .Parallel(), .Single() on WorkflowBuilder; .Loop()/.ParameterizedLoop() on LoopBuilder) instead of separate Build* methods. Name and Activity are required before Build. - WorkflowBuilder: remove public BuildPipeline/BuildParallel/BuildSingle; add Name, TaskQueue, Activity, Pipeline, Parallel, Single setters; add single Build - LoopBuilder: add Name, TaskQueue, Activity, Loop, ParameterizedLoop setters; add single Build; keep BuildLoop/BuildParameterizedLoop for raw-input callers - function/patterns: rewrite pipeline.go and parallel.go to build inputs directly without the now-removed Build* helpers - examples/function: update builder.go to use new API; fix temporal.NewClient two-return-value signature across all example files
…peline()/.Parallel()/.Single() Collapses the container WorkflowBuilder and LoopBuilder to match the function builder pattern from Task 16: Name()/TaskQueue() fluent setters, Pipeline()/Parallel()/Single() mode selectors, and a single Build() that returns *job.Definition. Updates NewWorkflowBuilder() to accept only BuilderOption args (name moved to .Name()). Keeps BuildPipeline/BuildParallel/ BuildSingle public for backward compatibility with patterns and callers that need raw payload types. Adds LoopBuilder.Build() with Loop/ParameterizedLoop mode inference from constructor. Updates patterns, examples accordingly.
Drop the removed io.Closer return from temporal.NewClient (3→2 values), migrate datasync builder.go from dsworkflow.RegisterJob/BuildWorkflowInput to def.Register/def.Execute, and handle the new 2-value Build() return in chunk_basic.go using *job.Definition instead of FullJobRegistration.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Consume the new
pkg/temporal/jobpackage and converge all four go-wf builders on producing*job.Definition. Removesdatasync/workflow.FullJobRegistrationandBuildJobRegistration.What changed
Idempotency refactor (Tasks 12-13):
container.RegisterAllandfunction.RegisterAllnow route every workflow/activity registration throughjob.RegisterWorkflowOnce/job.RegisterActivityOnce. Multiple Definitions backing the same workflow type can safely call RegisterAll concurrently.Builder convergence:
datasync/builder.SyncJobBuilder.Build()now returns(*job.Definition, error)(was(datasync.Job[T,U], error)).datasync/chunk.ChunkedSync.Build()/DateChunkedSync.Build()now return(*job.Definition, error); schedule via new fluent setters.ScheduleEvery(d)/.ScheduleCron(expr)/.ScheduleRaw(spec).function/builder.WorkflowBuilderandLoopBuildercollapsed to singleBuild() *job.Definitionwith mode setters.Pipeline()/.Parallel()/.Single()/.Loop()/.ParameterizedLoop()+ identity setters.Name(string)/.TaskQueue(string)/.Activity(fn).container/builder.WorkflowBuilderandLoopBuildersame shape, default task queuecontainer-<name>.NewWorkflowBuilder()no longer takes name as first arg — use.Name(...).Deletions:
datasync/workflow.FullJobRegistration(struct)datasync/workflow.BuildJobRegistration(function)BuildPipeline/BuildParallel/BuildSingle/BuildLoop/BuildParameterizedLoop/BuildDAG/BuildParameterizedDAGmethods on the L1 builders (internalbuild*Inputprivate helpers retained).Examples updated (15 files) for the new
temporal.NewClient2-return signature,*job.DefinitionAPI, and chunk's newBuild() (*job.Definition, error).Spec
docs/superpowers/specs/2026-05-11-pkg-temporal-job-definition-design.md
Depends on
pkg/temporal/job) — already merged. go.mod bumped to v2.12.1-0.20260511.Test plan