Skip to content

Conversation

@maxdml
Copy link
Collaborator

@maxdml maxdml commented Aug 22, 2025

Implement Conductor client.

Design

A conductor object is attached to a DBOSContext. Its lifecycle management is done like other resources, inside DBOSContext Launch and Shutdown methods.

The conductor operates through two goroutines a "main" goroutine handling conductor messages, and a "ping" goroutine to keep the connection alive.

Main goroutine

  • Handles connecting to conductor
  • Handles responding to conductor message
  • Will stop only if its context is cancelled (root DBOSContext)

The main goroutine is entirely responsible for managing the connection: whenever it detects it should connect to the server, it'll start a ping goroutine. Whenever it gets an error (e.g., reading on the websocket or sending a message), it will set the connection for closing.

Ping goroutine

  • Periodically sends keepalive pings to the server
  • Handles pong answers

The ping goutine will exit and signal the connection should be close if:

  • Its context is cancelled or
  • It gets an error trying to send the ping

Others

  • There cannot be concurrent writers on the websocket, so all write operations are protected by a mutex
  • Shutdown logic: we cancel the ping goroutine, close the connection and wait for both goroutine to terminate.
  • Add a missing executors ID filter on ListWorkflows

Comment on lines +716 to +726
// If no queue name was specified, only include workflows that have a queue name
var filteredWorkflows []WorkflowStatus
if req.Body.QueueName == nil {
for _, wf := range workflows {
if wf.QueueName != "" {
filteredWorkflows = append(filteredWorkflows, wf)
}
}
} else {
filteredWorkflows = workflows
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note that I'll eventually add a filter that'll go down the SQL query (while maintaining the simplified listing UX)

@maxdml maxdml marked this pull request as ready for review August 25, 2025 23:40
dbos/dbos.go Outdated

// Initialize conductor if API key is provided
if config.ConductorAPIKey != "" {
if initExecutor.executorID == "local" {
Copy link
Member

@kraftp kraftp Aug 27, 2025

Choose a reason for hiding this comment

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

It's safer to just always generate a new ID here. Otherwise, there's potential for trouble--multiple servers sharing the same ID, for example.

AppName: inputConfig.AppName,
Logger: inputConfig.Logger,
AdminServer: inputConfig.AdminServer,
DatabaseURL: inputConfig.DatabaseURL,
Copy link
Member

Choose a reason for hiding this comment

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

Application version should also be an option here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm adding this and executor ID in a different PR

@maxdml maxdml merged commit c260ad0 into main Aug 27, 2025
2 checks passed
@maxdml maxdml deleted the conductor branch August 27, 2025 17:22
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.

3 participants