Documentation
¶
Overview ¶
Package catalog lets workflows label themselves, and lets applications find workflows by label.
A label is a string pair such as lifecycle=install, stored in the entry metadata under the reserved prefix "label:". The engine does not interpret labels; this package does.
Label rules:
- One value per label. Passing the same label option twice keeps the last value.
- Labels are set when the workflow is registered and cannot change afterwards, because metadata values never change.
- Label names use lowercase letters, digits, dots and dashes, and start and end with a letter or digit.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMetadataUnsupported = errors.New("workflow entry does not support metadata")
ErrMetadataUnsupported is returned by Register when labels were requested but the entry does not support metadata. The workflow stays registered without labels.
Functions ¶
func FindByLifecycle ¶ added in v0.46.0
func FindByLifecycle(engine workflow.Engine, lifecycle Lifecycle) []workflow.Identifier
FindByLifecycle returns the IDs of the workflows of the engine that are labeled lifecycle=<lifecycle>, sorted by ID.
The result is a snapshot. Entries without metadata support are skipped. A workflow that is removed or replaced between listing and lookup is skipped or seen as its current entry; it never causes a panic. The engine is only used through its workflow.Engine methods, so wrapped engines work.
func Register ¶
func Register(engine workflow.Engine, id workflow.Identifier, config workflow.ConfigurationOptions, callback workflow.Callback, opts ...RegisterOption) (workflow.Entry, error)
Register registers a workflow with the engine and labels it with the given options.
Without options it behaves exactly like engine.Register. An error from engine.Register is returned unchanged, together with the entry that engine.Register returned, which is nil. If the entry does not support metadata, Register returns the entry together with ErrMetadataUnsupported; the workflow stays registered without labels.
Types ¶
type RegisterOption ¶
RegisterOption sets a label on a workflow when it is registered.
func WithLifecycle ¶
func WithLifecycle(lifecycle Lifecycle) RegisterOption
WithLifecycle labels the workflow with lifecycle=<lifecycle>.