Documentation
¶
Index ¶
- type Diff
- type Handler
- type RollbackFunc
- type VersionStore
- func (s *VersionStore) Count(workflowName string) int
- func (s *VersionStore) Get(workflowName string, version int) (*WorkflowVersion, bool)
- func (s *VersionStore) Latest(workflowName string) (*WorkflowVersion, bool)
- func (s *VersionStore) List(workflowName string) []*WorkflowVersion
- func (s *VersionStore) ListWorkflows() []string
- func (s *VersionStore) Save(workflowName, configYAML, description, createdBy string) (*WorkflowVersion, error)
- type WorkflowVersion
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.
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 ¶
RegisterRoutes registers versioning API routes on the given mux.
type RollbackFunc ¶
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.