reg

package
v0.8.17 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package reg implements a temporal.io workflow singleton worker and query functions to keep a global registry of all available fse workflow types

Index

Constants

View Source
const (
	// QueryWorkflowWorkflowsAdmin lists all known workflows of all versions (admin mode). It has no parameters.
	QueryWorkflowWorkflowsAdmin = "workflows"
	// QueryWorkflowWorkflowsFor lists all newest versions of workflows for the given option and roles. It has two parameters: string and []string.
	QueryWorkflowWorkflowsFor = "workflows-for"
	// QueryWorkflowGetWorkflow lists zero or all workflows of the given Common ordered by Version descending. It has one parameter: Common.
	QueryWorkflowGetWorkflow = "get-workflow"
	// SignalWorkflowRegister is the signal's name to be passed to SignalWorkflow to register a new fse workflow type
	SignalWorkflowRegister = "register"
)
View Source
const (
	// TaskQueue is temporal's task queue name for hosting this Registry workflow
	TaskQueue = "_FSERegistry"
	// WorkflowID is this Registry workflow's ID as a singleton
	WorkflowID = "_FSEGlobal"
)

Variables

This section is empty.

Functions

func Register

func Register(ctx context.Context, cli client.Client, s Type) error

Register queries for a Type type, if it doesn't exist or is different, replace it. This function also starts the Registry workflow if there is no instance of it.

func Registry

func Registry(ctx workflow.Context) error

Registry is a singleton workflow worker function

func Versioned

func Versioned(ctx context.Context, cli client.Client, workflowName syntax.Unversioned) (syntax.Versioned, error)

Versioned returns the newest Version of a particular workflow type, if it doesn't exist, an error is returned

Types

type Common

type Common struct {
	WorkflowName syntax.Unversioned `json:"workflowName,omitempty"`
}

Common is the combined key for an FSE workflow description. All other fields of Start are dependent of this properties in terms of beeing registered with the Registry temporal workflow. In v1 this is the Workflow name only.

type Dependent

type Dependent struct {
	Version     syntax.Unversioned `json:"version,omitempty"`
	Option      string             `json:"option,omitempty"`
	Display     string             `json:"display,omitempty"`
	Description string             `json:"description,omitempty"`
	TaskQueue   string             `json:"taskQueue,omitempty"`
}

Dependent are automatically comparable attributes of an FSE workflow description. Workflows have an optional Version string. Any non empty Version is always newer than the empty Version and a lexicographically larger string is considered to be a newer version.

func (Dependent) OptionParsed

func (d Dependent) OptionParsed() option.Option

OptionParsed returns Option parsed as option.Option or empty options if invalid

type Statename added in v0.5.6

type Statename struct {
	Name    string `json:"name,omitempty"`
	Display string `json:"display,omitempty"`
}

Statename describes a workflow state by key and display text

type Type

type Type struct {
	Common
	Dependent
	Roles      []string    `json:"roles,omitempty"`
	Statenames []Statename `json:"statenames,omitempty"`
}

Type describes an FSE workflow

func Versions

func Versions(ctx context.Context, cli client.Client, workflowName syntax.Unversioned) ([]Type, error)

Versions returns all Versions sorted newer to older of a particular workflow type

func Workflows

func Workflows(ctx context.Context, cli client.Client) ([]Type, error)

Workflows returns all currently registered workflows

func WorkflowsOf

func WorkflowsOf(ctx context.Context, cli client.Client, option string, roles []string) ([]Type, error)

WorkflowsOf returns all currently registered workflows filtered by option and a list of roles

func (Type) Equals

func (s Type) Equals(s2 Type) bool

Equals is true, if all attributes match and the Roles slices are index-wise equal

func (Type) IntersectsWith

func (s Type) IntersectsWith(roles []string) bool

IntersectsWith is true if e.Roles is empty or otherwise if there is a non-empty intersection between e.Roles and the given roles

Jump to

Keyboard shortcuts

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