Skip to content

Conversation

@PhakornKiong
Copy link
Contributor

Adds exported methods to list registered workflows and scheduled workflows with their registration parameters.

Resolves #150

@maxdml maxdml self-assigned this Sep 28, 2025
Copy link
Collaborator

@maxdml maxdml left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR, @PhakornKiong. This is going on a good direction!

I think we can just reuse the existing workflowRegistryEntry, make it public and add a CronSchedule property, instead of adding two new types.

This also means we can keep using a single map to store all the workflows. The list functions can filter in/out the scheduled workflows.

Comment on lines 4154 to 4158
if dbosCtx.(*dbosContext).workflowScheduler != nil {
ctx := dbosCtx.(*dbosContext).workflowScheduler.Stop()
<-ctx.Done() // Wait for it to stop
dbosCtx.(*dbosContext).workflowScheduler = nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't have to do this: setupDBOS calls Shutdown on the context, which stops the scheduler.

Copy link
Contributor Author

@PhakornKiong PhakornKiong Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I was getting the following error. Realized that I did not launch dbos. Just sharing here for future reference

time=2025-10-01T03:38:37.431+08:00 level=INFO msg="Initializing DBOS context" app_name=test-app dbos_version=(devel)
time=2025-10-01T03:38:37.432+08:00 level=INFO msg="Connecting to system database" database_url="postgres://postgres:***@localhost:5432/dbos?sslmode=disable" schema=dbos
time=2025-10-01T03:38:38.111+08:00 level=INFO msg="Registered scheduled workflow" fqn=github.com/dbos-inc/dbos-transact-golang/dbos.simpleWorkflowWithSchedule cron_schedule="0 0 * * * *"
time=2025-10-01T03:38:38.111+08:00 level=INFO msg="Cleaning up DBOS instance..."
--- FAIL: TestRegisteredWorkflowListing (1.28s)
   /dbos/dbos-transact-golang/dbos/utils_test.go:76: found unexpected goroutines:
        [Goroutine 50 in state select, with github.com/robfig/cron/v3.(*Cron).run on top of the stack:
        github.com/robfig/cron/v3.(*Cron).run(0xc00032a320)
        	/go/pkg/mod/github.com/robfig/cron/[email protected]/cron.go:263 +0xdf0
        created by github.com/robfig/cron/v3.(*Cron).Start in goroutine 19
        	/go/pkg/mod/github.com/robfig/cron/[email protected]/cron.go:222 +0x100
        ]
FAIL
FAIL	github.com/dbos-inc/dbos-transact-golang/dbos	1.613s

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This must be because we do start the scheduler in registerScheduledWorkflow. We should do it in Launch only. I'll fix it!

@PhakornKiong
Copy link
Contributor Author

Thanks for the PR, @PhakornKiong. This is going on a good direction!

I think we can just reuse the existing workflowRegistryEntry, make it public and add a CronSchedule property, instead of adding two new types.

This also means we can keep using a single map to store all the workflows. The list functions can filter in/out the scheduled workflows.

I've updated the PR with the following changes:

  • Expose WorkflowRegistryEntry
  • Add FQN to WorkflowRegistryEntry
  • Implement filtering for ListRegisteredWorkflows() with functional option pattern

Copy link
Collaborator

@maxdml maxdml left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks @PhakornKiong. Let's just make WrappedFunction private -- no need to expose it to the public API.

dbos/queue.go Outdated
}

_, err := registeredWorkflow.wrappedFunction(ctx, input, WithWorkflowID(workflow.id))
_, err := registeredWorkflow.WrappedFunction(ctx, input, WithWorkflowID(workflow.id))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the wrapped function private -- no need to expose it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

dbos/workflow.go Outdated

// ListRegisteredWorkflows returns information about workflows registered with DBOS.
// Each WorkflowRegistryEntry contains:
// - WrappedFunction: The underlying workflow implementation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: update go doc too

@maxdml maxdml merged commit 969d588 into dbos-inc:main Oct 2, 2025
3 checks passed
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.

Add interface/package methods to list workflow registry methods

2 participants