Documentation
¶
Index ¶
- type ExecutionStatus
- type JSONMap
- type Service
- func (s *Service) CancelExecution(ctx context.Context, userID string, executionID uint) error
- func (s *Service) CreateWorkflow(ctx context.Context, workflow *Workflow) error
- func (s *Service) DeleteWorkflow(ctx context.Context, userID string, workflowID uint) error
- func (s *Service) ExecuteWorkflow(ctx context.Context, userID string, workflowID uint, ...) (*WorkflowExecution, error)
- func (s *Service) GetExecutionStatus(ctx context.Context, userID string, executionID uint) (*WorkflowExecution, error)
- func (s *Service) GetWorkflow(ctx context.Context, userID string, workflowID uint) (*Workflow, error)
- func (s *Service) ListExecutions(ctx context.Context, userID string, workflowID uint) ([]*WorkflowExecution, error)
- func (s *Service) ListWorkflows(ctx context.Context, userID string) ([]*Workflow, error)
- func (s *Service) SetDB(db *gorm.DB)
- func (s *Service) UpdateWorkflow(ctx context.Context, userID string, workflow *Workflow) error
- type StepExecution
- type StepType
- type Workflow
- type WorkflowExecution
- type WorkflowStatus
- type WorkflowStep
- type WorkflowTemplate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecutionStatus ¶
type ExecutionStatus int
ExecutionStatus represents the status of a workflow execution
const ( ExecutionStatusPending ExecutionStatus = iota ExecutionStatusRunning ExecutionStatusCompleted ExecutionStatusFailed ExecutionStatusCancelled )
func (ExecutionStatus) String ¶
func (e ExecutionStatus) String() string
String returns the string representation of ExecutionStatus
type JSONMap ¶
type JSONMap map[string]interface{}
JSONMap is a custom type for handling JSON maps in GORM
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides workflow management functionality
func (*Service) CancelExecution ¶
CancelExecution cancels a running workflow execution
func (*Service) CreateWorkflow ¶
CreateWorkflow creates a new workflow
func (*Service) DeleteWorkflow ¶
DeleteWorkflow deletes a workflow
func (*Service) ExecuteWorkflow ¶
func (s *Service) ExecuteWorkflow(ctx context.Context, userID string, workflowID uint, input map[string]interface{}) (*WorkflowExecution, error)
ExecuteWorkflow starts a new workflow execution
func (*Service) GetExecutionStatus ¶
func (s *Service) GetExecutionStatus(ctx context.Context, userID string, executionID uint) (*WorkflowExecution, error)
GetExecutionStatus retrieves the status of a workflow execution
func (*Service) GetWorkflow ¶
func (s *Service) GetWorkflow(ctx context.Context, userID string, workflowID uint) (*Workflow, error)
GetWorkflow retrieves a workflow by ID
func (*Service) ListExecutions ¶
func (s *Service) ListExecutions(ctx context.Context, userID string, workflowID uint) ([]*WorkflowExecution, error)
ListExecutions returns all executions for a workflow
func (*Service) ListWorkflows ¶
ListWorkflows returns all workflows for a user
type StepExecution ¶
type StepExecution struct {
ID uint `json:"id" gorm:"primaryKey"`
ExecutionID uint `json:"execution_id" gorm:"index;not null"`
StepID uint `json:"step_id" gorm:"index;not null"`
Status ExecutionStatus `json:"status" gorm:"default:0"`
Input JSONMap `json:"input" gorm:"type:text"`
Output JSONMap `json:"output" gorm:"type:text"`
Error string `json:"error"`
StartedAt time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at"`
Attempt int `json:"attempt" gorm:"default:1"`
}
StepExecution represents the execution of a workflow step
func (StepExecution) TableName ¶
func (StepExecution) TableName() string
TableName returns the table name for the StepExecution model
type Workflow ¶
type Workflow struct {
ID uint `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"not null"`
Description string `json:"description"`
UserID string `json:"user_id" gorm:"index;not null"`
Status WorkflowStatus `json:"status" gorm:"default:0"`
Steps []WorkflowStep `json:"steps" gorm:"foreignKey:WorkflowID;constraint:OnDelete:CASCADE"`
Variables JSONMap `json:"variables" gorm:"type:text"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `json:"-" gorm:"index"`
}
Workflow represents a workflow definition
type WorkflowExecution ¶
type WorkflowExecution struct {
ID uint `json:"id" gorm:"primaryKey"`
WorkflowID uint `json:"workflow_id" gorm:"index;not null"`
UserID string `json:"user_id" gorm:"index;not null"`
Status ExecutionStatus `json:"status" gorm:"default:0"`
Input JSONMap `json:"input" gorm:"type:text"`
Output JSONMap `json:"output" gorm:"type:text"`
Error string `json:"error"`
StartedAt time.Time `json:"started_at"`
CompletedAt *time.Time `json:"completed_at"`
Steps []StepExecution `json:"steps" gorm:"foreignKey:ExecutionID;constraint:OnDelete:CASCADE"`
}
WorkflowExecution represents an execution of a workflow
func (WorkflowExecution) TableName ¶
func (WorkflowExecution) TableName() string
TableName returns the table name for the WorkflowExecution model
type WorkflowStatus ¶
type WorkflowStatus int
WorkflowStatus represents the status of a workflow
const ( WorkflowStatusDraft WorkflowStatus = iota WorkflowStatusActive WorkflowStatusInactive )
func (WorkflowStatus) String ¶
func (w WorkflowStatus) String() string
String returns the string representation of WorkflowStatus
type WorkflowStep ¶
type WorkflowStep struct {
ID uint `json:"id" gorm:"primaryKey"`
WorkflowID uint `json:"workflow_id" gorm:"index;not null"`
Name string `json:"name" gorm:"not null"`
Type StepType `json:"type" gorm:"not null"`
Config JSONMap `json:"config" gorm:"type:text"`
Order int `json:"order" gorm:"not null"`
DependsOn []uint `json:"depends_on" gorm:"serializer:json"`
Timeout int `json:"timeout" gorm:"default:300"` // seconds
Retries int `json:"retries" gorm:"default:0"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
WorkflowStep represents a step in a workflow
func (WorkflowStep) TableName ¶
func (WorkflowStep) TableName() string
TableName returns the table name for the WorkflowStep model
type WorkflowTemplate ¶
type WorkflowTemplate struct {
ID uint `json:"id" gorm:"primaryKey"`
Name string `json:"name" gorm:"not null"`
Description string `json:"description"`
Category string `json:"category"`
Template JSONMap `json:"template" gorm:"type:text"`
Public bool `json:"public" gorm:"default:false"`
CreatedBy string `json:"created_by" gorm:"not null"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
}
WorkflowTemplate represents a reusable workflow template
func (WorkflowTemplate) TableName ¶
func (WorkflowTemplate) TableName() string
TableName returns the table name for the WorkflowTemplate model