workflowcore

package
v0.139.2 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResolutionSourceBindingContentType = "binding_content_type"
	ResolutionSourceBindingTrait       = "binding_trait"
	ResolutionSourceBindingGlobal      = "binding_global"
)

Variables

View Source
var (
	ErrWorkflowVersionConflict         = errors.New("workflow version conflict")
	ErrWorkflowBindingConflict         = errors.New("workflow binding conflict")
	ErrWorkflowBindingVersionConflict  = errors.New("workflow binding version conflict")
	ErrWorkflowRollbackVersionNotFound = errors.New("workflow rollback version not found")
)

Functions

func BindingMatchesEnvironment

func BindingMatchesEnvironment(binding WorkflowBinding, environment string) bool

func CanonicalMachineIDForWorkflow

func CanonicalMachineIDForWorkflow(workflow PersistedWorkflow) string

func CanonicalMachineVersionForWorkflow

func CanonicalMachineVersionForWorkflow(workflow PersistedWorkflow) string

func NormalizeBindingTraits

func NormalizeBindingTraits(raw []string) []string

func SortWorkflowBindingsForResolution

func SortWorkflowBindingsForResolution(bindings []WorkflowBinding)

func WorkflowBindingConflictKey

func WorkflowBindingConflictKey(binding WorkflowBinding) string

Types

type PersistedWorkflow

type PersistedWorkflow struct {
	ID             string                  `json:"id"`
	MachineID      string                  `json:"machine_id,omitempty"`
	MachineVersion string                  `json:"machine_version,omitempty"`
	Name           string                  `json:"name"`
	Definition     WorkflowDefinition      `json:"definition"`
	Status         PersistedWorkflowStatus `json:"status"`
	Version        int                     `json:"version"`
	Environment    string                  `json:"environment,omitempty"`
	CreatedAt      time.Time               `json:"created_at"`
	UpdatedAt      time.Time               `json:"updated_at"`
}

PersistedWorkflow stores a workflow definition with lifecycle metadata.

func ClonePersistedWorkflow

func ClonePersistedWorkflow(in PersistedWorkflow) PersistedWorkflow

func NormalizePersistedWorkflow

func NormalizePersistedWorkflow(in PersistedWorkflow) PersistedWorkflow

type PersistedWorkflowListOptions

type PersistedWorkflowListOptions struct {
	Status      PersistedWorkflowStatus `json:"status"`
	Environment string                  `json:"environment"`
}

PersistedWorkflowListOptions filters workflow list queries.

type PersistedWorkflowStatus

type PersistedWorkflowStatus string

PersistedWorkflowStatus controls rollout state for stored workflow definitions.

const (
	WorkflowStatusDraft      PersistedWorkflowStatus = "draft"
	WorkflowStatusActive     PersistedWorkflowStatus = "active"
	WorkflowStatusDeprecated PersistedWorkflowStatus = "deprecated"
)

func (PersistedWorkflowStatus) IsValid

func (s PersistedWorkflowStatus) IsValid() bool

type WorkflowBinding

type WorkflowBinding struct {
	ID          string                   `json:"id"`
	ScopeType   WorkflowBindingScopeType `json:"scope_type"`
	ScopeRef    string                   `json:"scope_ref"`
	WorkflowID  string                   `json:"workflow_id"`
	Priority    int                      `json:"priority"`
	Status      WorkflowBindingStatus    `json:"status"`
	Environment string                   `json:"environment,omitempty"`
	Version     int                      `json:"version"`
	CreatedAt   time.Time                `json:"created_at"`
	UpdatedAt   time.Time                `json:"updated_at"`
}

WorkflowBinding stores a scoped workflow assignment.

func BindingCandidates

func BindingCandidates(bindings []WorkflowBinding, scopeType WorkflowBindingScopeType, scopeRef string, environment string) []WorkflowBinding

func CloneWorkflowBinding

func CloneWorkflowBinding(in WorkflowBinding) WorkflowBinding

func NormalizeWorkflowBinding

func NormalizeWorkflowBinding(in WorkflowBinding) WorkflowBinding

type WorkflowBindingConflictError

type WorkflowBindingConflictError struct {
	BindingID         string                   `json:"binding_id"`
	ExistingBindingID string                   `json:"existing_binding_id"`
	ScopeType         WorkflowBindingScopeType `json:"scope_type"`
	ScopeRef          string                   `json:"scope_ref"`
	Environment       string                   `json:"environment"`
	Priority          int                      `json:"priority"`
}

WorkflowBindingConflictError indicates duplicate active binding scope+priority+environment.

func (WorkflowBindingConflictError) Error

func (WorkflowBindingConflictError) Unwrap

type WorkflowBindingListOptions

type WorkflowBindingListOptions struct {
	ScopeType   WorkflowBindingScopeType `json:"scope_type"`
	ScopeRef    string                   `json:"scope_ref"`
	Environment string                   `json:"environment"`
	Status      WorkflowBindingStatus    `json:"status"`
}

WorkflowBindingListOptions filters binding list queries.

type WorkflowBindingResolution

type WorkflowBindingResolution struct {
	WorkflowID      string                   `json:"workflow_id"`
	WorkflowVersion int                      `json:"workflow_version,omitempty"`
	MachineID       string                   `json:"machine_id,omitempty"`
	MachineVersion  string                   `json:"machine_version,omitempty"`
	Source          string                   `json:"source"`
	BindingID       string                   `json:"binding_id,omitempty"`
	ScopeType       WorkflowBindingScopeType `json:"scope_type,omitempty"`
	ScopeRef        string                   `json:"scope_ref,omitempty"`
	Priority        int                      `json:"priority,omitempty"`
	Environment     string                   `json:"environment,omitempty"`
}

WorkflowBindingResolution describes the resolved binding winner.

func BindingResolutionFrom

func BindingResolutionFrom(binding WorkflowBinding, workflow PersistedWorkflow, source string) WorkflowBindingResolution

type WorkflowBindingResolveInput

type WorkflowBindingResolveInput struct {
	ContentType string   `json:"content_type"`
	Traits      []string `json:"traits"`
	Environment string   `json:"environment"`
}

WorkflowBindingResolveInput captures scope details used for runtime resolution.

type WorkflowBindingScopeType

type WorkflowBindingScopeType string

WorkflowBindingScopeType identifies where a binding applies.

const (
	WorkflowBindingScopeTrait       WorkflowBindingScopeType = "trait"
	WorkflowBindingScopeContentType WorkflowBindingScopeType = "content_type"
	WorkflowBindingScopeGlobal      WorkflowBindingScopeType = "global"
)

func (WorkflowBindingScopeType) IsValid

func (s WorkflowBindingScopeType) IsValid() bool

type WorkflowBindingStatus

type WorkflowBindingStatus string

WorkflowBindingStatus controls whether a binding participates in resolution.

const (
	WorkflowBindingStatusActive   WorkflowBindingStatus = "active"
	WorkflowBindingStatusInactive WorkflowBindingStatus = "inactive"
)

func (WorkflowBindingStatus) IsValid

func (s WorkflowBindingStatus) IsValid() bool

type WorkflowBindingVersionConflictError

type WorkflowBindingVersionConflictError struct {
	BindingID       string `json:"binding_id"`
	ExpectedVersion int    `json:"expected_version"`
	ActualVersion   int    `json:"actual_version"`
}

WorkflowBindingVersionConflictError indicates optimistic-lock mismatch for bindings.

func (WorkflowBindingVersionConflictError) Error

func (WorkflowBindingVersionConflictError) Unwrap

type WorkflowDefinition

type WorkflowDefinition struct {
	EntityType     string                       `json:"entity_type"`
	MachineVersion string                       `json:"machine_version"`
	InitialState   string                       `json:"initial_state"`
	Transitions    []cmsboot.WorkflowTransition `json:"transitions"`
}

WorkflowDefinition describes a state machine for a specific entity type.

func CloneWorkflowDefinition

func CloneWorkflowDefinition(in WorkflowDefinition) WorkflowDefinition

type WorkflowValidationErrors

type WorkflowValidationErrors struct {
	Fields map[string]string `json:"fields"`
}

WorkflowValidationErrors aggregates field-level workflow API validation issues.

func (WorkflowValidationErrors) Error

func (e WorkflowValidationErrors) Error() string

type WorkflowVersionConflictError

type WorkflowVersionConflictError struct {
	WorkflowID      string `json:"workflow_id"`
	ExpectedVersion int    `json:"expected_version"`
	ActualVersion   int    `json:"actual_version"`
}

WorkflowVersionConflictError indicates optimistic-lock mismatch for workflows.

func (WorkflowVersionConflictError) Error

func (WorkflowVersionConflictError) Unwrap

Jump to

Keyboard shortcuts

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