workflow

package
v0.3.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 16, 2026 License: MIT Imports: 35 Imported by: 0

Documentation

Overview

Package workflow implements DBOS-based durable workflows This is a proof of concept for migrating Drover to DBOS

Package workflow implements durable workflows using DBOS

Package workflow implements durable workflows using DBOS

DEPRECATED: This file contains the legacy SQLite-based Orchestrator. Drover now uses DBOS by default for both SQLite and PostgreSQL modes. See dbos_workflow.go for the current DBOS-based implementation. This file is kept for backwards compatibility and testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBOSOrchestrator

type DBOSOrchestrator struct {
	// contains filtered or unexported fields
}

DBOSOrchestrator manages workflow execution using DBOS

func NewDBOSOrchestrator

func NewDBOSOrchestrator(cfg *config.Config, dbosCtx dbos.DBOSContext, projectDir string, store *db.Store) (*DBOSOrchestrator, error)

NewDBOSOrchestrator creates a new DBOS-based orchestrator

func (*DBOSOrchestrator) ExecuteAllTasks

func (o *DBOSOrchestrator) ExecuteAllTasks(ctx dbos.DBOSContext, tasks []TaskInput) ([]TaskResult, error)

ExecuteAllTasks is the main DBOS workflow that processes all tasks sequentially This is the original implementation for comparison

func (*DBOSOrchestrator) ExecuteTaskWorkflow

func (o *DBOSOrchestrator) ExecuteTaskWorkflow(ctx dbos.DBOSContext, task TaskInput) (TaskResult, error)

ExecuteTaskWorkflow is a DBOS workflow that executes a single task This is a separate workflow so each task can be independently recovered

func (*DBOSOrchestrator) ExecuteTasksWithQueue

func (o *DBOSOrchestrator) ExecuteTasksWithQueue(ctx dbos.DBOSContext, input QueuedTasksInput) (QueueStats, error)

ExecuteTasksWithQueue executes tasks in parallel using DBOS queues This is the recommended approach for production use

func (*DBOSOrchestrator) ExecuteTasksWithQueueDirectly

func (o *DBOSOrchestrator) ExecuteTasksWithQueueDirectly(tasks []TaskInput) (QueueStats, error)

ExecuteTasksWithQueueDirectly executes tasks using DBOS queues from outside a workflow context. This is a helper method that can be called directly (not as a workflow) to enqueue tasks. This avoids the issue of trying to enqueue workflows from within a workflow.

func (*DBOSOrchestrator) OnTaskComplete

func (o *DBOSOrchestrator) OnTaskComplete(ctx dbos.DBOSContext, completedTaskID string) (int, error)

OnTaskComplete is called when a task completes and enqueues any dependent tasks

func (*DBOSOrchestrator) PrintQueueStats

func (o *DBOSOrchestrator) PrintQueueStats(stats QueueStats)

PrintQueueStats prints statistics about queue-based execution

func (*DBOSOrchestrator) PrintResults

func (o *DBOSOrchestrator) PrintResults(results []TaskResult)

PrintResults prints the final results of the workflow execution

func (*DBOSOrchestrator) RegisterWorkflows

func (o *DBOSOrchestrator) RegisterWorkflows() error

RegisterWorkflows registers all DBOS workflows and steps

func (*DBOSOrchestrator) Stop

func (o *DBOSOrchestrator) Stop()

Stop stops the orchestrator and cleans up resources

type GitManager

type GitManager interface {
	// Create creates a new worktree for a task and returns the worktree path.
	Create(task *types.Task) (string, error)

	// Commit commits changes for a task and returns whether there were changes.
	Commit(taskID, message string) (bool, error)

	// MergeToMain merges the worktree changes to the main branch.
	MergeToMain(taskID string) error

	// Remove cleans up a worktree for a task.
	Remove(taskID string) error

	// Cleanup cleans up all worktrees.
	Cleanup() error

	// SetVerbose enables or disables verbose logging.
	SetVerbose(v bool)

	// PruneStale cleans up stale worktree artifacts for a task.
	PruneStale(taskID string)

	// GetWorktreePath returns the filesystem path for a task's worktree.
	GetWorktreePath(taskID string) (string, error)
}

GitManager defines the interface for git worktree operations needed by the orchestrator. This abstraction allows for testing with mock implementations.

type Orchestrator

type Orchestrator struct {
	// contains filtered or unexported fields
}

Orchestrator manages the main execution loop

func NewOrchestrator

func NewOrchestrator(cfg *config.Config, store *db.Store, projectDir string) (*Orchestrator, error)

NewOrchestrator creates a new workflow orchestrator

func (*Orchestrator) Run

func (o *Orchestrator) Run(ctx context.Context) error

Run executes all tasks to completion

func (*Orchestrator) SetEpicFilter

func (o *Orchestrator) SetEpicFilter(epicID string)

SetEpicFilter sets the epic filter for task execution Only tasks belonging to the specified epic will be executed

type QueueStats

type QueueStats struct {
	TotalEnqueued int
	Completed     int
	Failed        int
	Duration      time.Duration
}

QueueStats represents statistics about queue execution

type QueuedTasksInput

type QueuedTasksInput struct {
	Tasks []TaskInput
}

QueuedTasksInput represents input for the queue-based workflow

type TaskInput

type TaskInput struct {
	TaskID      string
	Title       string
	Description string
	EpicID      string
	Priority    int
	MaxAttempts int
	// BlockedBy lists task IDs that must complete before this task can run
	BlockedBy []string
}

TaskInput represents the input for a task execution step

type TaskResult

type TaskResult struct {
	Success    bool
	Output     string
	Error      string
	Duration   time.Duration
	HasChanges bool
	CommitHash string
}

TaskResult represents the output of a task execution step

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL