You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Expose active workflow instances on WorkflowDefinition #1677
Expose the full set of active (non-terminal) WorkflowInstances tracked by a WorkflowDefinition, similar to the existing scheduledInstances() accessor.
WorkflowDefinition (impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowDefinition.java) already keeps every running instance in an internal map:
There's no way to enumerate all active instances for a definition. Meanwhile, scheduledInstances already has a bulk accessor that returns an unmodifiable view:
In quarkus-flow we're adding a REST endpoint that lists the in-memory active workflow instances on a runner pod, so a rebalancer service can tell which instances are actively being processed on a given pod vs. only persisted in the DB (see PR #892).
Since the SDK doesn't expose this today, the current implementation duplicates the tracking with a separate ActiveInstanceRegistry that listens to WorkflowExecutionListener lifecycle events and maintains its own copy of the same data WorkflowDefinition already holds internally.
As pointed out in review feedback by @fjtirado, this duplication isn't necessary — WorkflowDefinition is already the source of truth for active instances, it just isn't public. Exposing activeInstances() (mirroring scheduledInstances()) would let quarkus-flow (and other SDK consumers) query this directly instead of re-implementing the same bookkeeping, and let us drop ActiveInstanceRegistry in favor of the new method.
Activity