Skip to content

refactor(temporal): extract workflow registration into WorkflowRegistry and TemporalWorkers - #2322

Open
lschim wants to merge 2 commits into
mainfrom
refactor/split-workflow-registration
Open

refactor(temporal): extract workflow registration into WorkflowRegistry and TemporalWorkers#2322
lschim wants to merge 2 commits into
mainfrom
refactor/split-workflow-registration

Conversation

@lschim

@lschim lschim commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Why

The discovery of Workflows was hardcoded on detecting single activity workflows annotated with @WorkflowInterface, the PR offers a way to register different types of Workflows.

Also, TemporalInterlocutor carried three responsibilities: talking to Temporal, knowing the naming convention that maps a workflow interface to its implementation and activity, and owning the lifecycle of the workers serving them. This PR extracts the last two; the interlocutor is a Temporal client again.

It is also the occasion to widen the possibilities of queue management and ease of starting workers.

The two extracted classes

  • WorkflowRegistry : what should be served, and on which queue. Manual registration, discovery by naming convention, read views. No Temporal dependency at all, no client.
  • TemporalWorkers.start(client, registry, listeningQueues, options) — starts the workers and returns the Closeable. The only part that knows about WorkerFactory.

The substantive change: when the routing decision is made

Discovery used to drop every workflow that did not belong to the worker's group (makeWorkflowFilter(routingStrategy, group)), so a process could only ever serve one queue.

The registry now registers everything it finds, keyed by the queue the routing strategy resolves, and TemporalWorkers.start picks which of those queues to poll. A distributed deployment can serve a subset; CommonMode serves everything it discovered. This is what unblocks the fan-out.

@lschim lschim changed the title refactor(temporal): extract workflow discovery and registration into WorkflowRegistrar refactor(temporal): extract workflow registration into WorkflowRegistry and TemporalWorkers Aug 13, 2026
@lschim
lschim marked this pull request as draft August 13, 2026 09:00
@lschim
lschim force-pushed the refactor/split-workflow-registration branch 6 times, most recently from e03a03a to 3fee0c8 Compare August 14, 2026 15:57
lschim added 2 commits August 14, 2026 18:20
…rlocutor

WorkflowRegistry holds what to serve and on which queue, TemporalWorkers starts
the workers. Discovery no longer drops workflows outside the worker's group, so
the queues a process serves are chosen at startup rather than at discovery.
 This value requires to be bigger than one because of the sticky queues mechanism in Temporal. With only one workflow task slot only one poll is ever in flight, and the sticky balancer always assigns it to the sticky queue, leaving new workflows stranded on the normal queue for a full 60s long poll.
@lschim
lschim force-pushed the refactor/split-workflow-registration branch from 3fee0c8 to 2844b7b Compare August 14, 2026 16:20
@lschim
lschim marked this pull request as ready for review August 14, 2026 16:26
@lschim
lschim requested a review from a team August 14, 2026 16:33
@mvanzalu mvanzalu self-assigned this Aug 17, 2026
@mvanzalu

Copy link
Copy Markdown
Contributor

LGTM !

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.

2 participants