versioning

package
v0.0.0-...-dac86b4 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diff

type Diff struct {
	WorkflowName string `json:"workflowName"`
	FromVersion  int    `json:"fromVersion"`
	ToVersion    int    `json:"toVersion"`
	FromConfig   string `json:"fromConfig"`
	ToConfig     string `json:"toConfig"`
	Changed      bool   `json:"changed"`
}

Diff represents changes between two versions.

func Compare

func Compare(store *VersionStore, workflowName string, fromVersion, toVersion int) (*Diff, error)

Compare returns a diff between two versions.

type Handler

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

Handler provides HTTP endpoints for workflow versioning.

func NewHandler

func NewHandler(store *VersionStore, applyFn RollbackFunc) *Handler

NewHandler creates a new versioning HTTP handler.

func (*Handler) RegisterRoutes

func (h *Handler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes registers versioning API routes on the given mux.

type RollbackFunc

type RollbackFunc func(workflowName, configYAML string) error

RollbackFunc is called to apply a restored configuration.

type VersionStore

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

VersionStore persists workflow versions in memory.

func NewVersionStore

func NewVersionStore() *VersionStore

NewVersionStore creates a new VersionStore.

func (*VersionStore) Count

func (s *VersionStore) Count(workflowName string) int

Count returns the number of versions for a workflow.

func (*VersionStore) Get

func (s *VersionStore) Get(workflowName string, version int) (*WorkflowVersion, bool)

Get retrieves a specific version of a workflow.

func (*VersionStore) Latest

func (s *VersionStore) Latest(workflowName string) (*WorkflowVersion, bool)

Latest returns the latest version of a workflow.

func (*VersionStore) List

func (s *VersionStore) List(workflowName string) []*WorkflowVersion

List returns all versions for a workflow, newest first.

func (*VersionStore) ListWorkflows

func (s *VersionStore) ListWorkflows() []string

ListWorkflows returns the names of all workflows that have versions.

func (*VersionStore) Save

func (s *VersionStore) Save(workflowName, configYAML, description, createdBy string) (*WorkflowVersion, error)

Save stores a new version of a workflow. It auto-increments the version number.

type WorkflowVersion

type WorkflowVersion struct {
	WorkflowName string    `json:"workflowName"`
	Version      int       `json:"version"`
	ConfigYAML   string    `json:"configYaml"`
	Description  string    `json:"description,omitempty"`
	CreatedBy    string    `json:"createdBy,omitempty"`
	CreatedAt    time.Time `json:"createdAt"`
}

WorkflowVersion represents a versioned snapshot of a workflow configuration.

func Rollback

func Rollback(store *VersionStore, workflowName string, targetVersion int, createdBy string, apply RollbackFunc) (*WorkflowVersion, error)

Rollback restores a previous version and saves it as a new version. The apply function is called to apply the config; if it returns an error the rollback is aborted.

Jump to

Keyboard shortcuts

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