workflow

package
v0.0.0-...-a5f9fc7 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 14 Imported by: 11

Documentation

Index

Constants

View Source
const (
	Content_type_key     string = "Content-Type"
	Content_location_key string = "Content-Location"
)

Variables

This section is empty.

Functions

func FlagsetFromConfigurationOptions

func FlagsetFromConfigurationOptions(param ConfigurationOptions) *pflag.FlagSet

FlagsetFromConfigurationOptions extracts the pflag.FlagSet from a ConfigurationOptions implementation.

func GetCommandFromWorkflowIdentifier

func GetCommandFromWorkflowIdentifier(id Identifier) string

GetCommandFromWorkflowIdentifier returns the command string from a workflow identifier. It returns an empty string if the identifier is not a workflow identifier.

func JsonFromConfigurationOptions

func JsonFromConfigurationOptions(param ConfigurationOptions) []byte

Types

type Callback

type Callback func(invocation InvocationContext, input []Data) ([]Data, error)

type ConfigurationOptions

type ConfigurationOptions interface {
}

ConfigurationOptions is an interface that can be implemented by any type that can be used to pass configuration options to a workflow.

func ConfigurationOptionsFromFlagset

func ConfigurationOptionsFromFlagset(flagset *pflag.FlagSet) ConfigurationOptions

ConfigurationOptionsFromFlagset implements the ConfigurationOptions interface. It returns a ConfigurationOptionsImpl instance that wraps the given pflag.FlagSet.

func ConfigurationOptionsFromJson

func ConfigurationOptionsFromJson(bytes []byte) ConfigurationOptions

func GetGlobalConfiguration

func GetGlobalConfiguration() ConfigurationOptions

GetGlobalConfiguration returns the global configuration options.

type ConfigurationOptionsImpl

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

ConfigurationOptionsImpl is a wrapper around a pflag.FlagSet.

type Data

type Data interface {
	SetMetaData(key string, value string)
	GetMetaData(key string) (string, error)
	SetPayload(payload interface{})
	GetPayload() interface{}
	GetIdentifier() Identifier
	GetContentType() string
	GetContentLocation() string
	SetContentLocation(string)
}

Data is an interface that wraps the methods that are used to manage data that is passed between workflows.

func NewData

func NewData(id Identifier, contentType string, payload interface{}) Data

NewData creates a new data instance.

func NewDataFromInput

func NewDataFromInput(input Data, typeIdentifier Identifier, contentType string, payload interface{}) Data

NewDataFromInput creates a new data instance from the given input data.

type DataImpl

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

DataImpl is the default implementation of the Data interface.

func (*DataImpl) GetContentLocation

func (d *DataImpl) GetContentLocation() string

GetContentLocation returns the Content-Location header of the given data instance.

func (*DataImpl) GetContentType

func (d *DataImpl) GetContentType() string

GetContentType returns the Content-Type header of the given data instance.

func (*DataImpl) GetIdentifier

func (d *DataImpl) GetIdentifier() Identifier

GetIdentifier returns the identifier of the given data instance.

func (*DataImpl) GetMetaData

func (d *DataImpl) GetMetaData(key string) (string, error)

GetMetaData returns the value of the given header key.

func (*DataImpl) GetPayload

func (d *DataImpl) GetPayload() interface{}

GetPayload returns the payload of the given data instance.

func (*DataImpl) SetContentLocation

func (d *DataImpl) SetContentLocation(location string)

SetContentLocation sets the Content-Location header of the given data instance.

func (*DataImpl) SetMetaData

func (d *DataImpl) SetMetaData(key string, value string)

SetMetaData sets the headers of the given data instance.

func (*DataImpl) SetPayload

func (d *DataImpl) SetPayload(payload interface{})

SetPayload sets the payload of the given data instance.

func (*DataImpl) String

func (d *DataImpl) String() string

String returns a string representation of the given data instance.

type Engine

type Engine interface {
	Init() error
	AddExtensionInitializer(initializer ExtensionInit)
	Register(id Identifier, config ConfigurationOptions, callback Callback) (Entry, error)
	GetWorkflows() []Identifier
	GetWorkflow(id Identifier) (Entry, bool)
	Invoke(id Identifier) ([]Data, error)
	InvokeWithInput(id Identifier, input []Data) ([]Data, error)
	InvokeWithConfig(id Identifier, config configuration.Configuration) ([]Data, error)
	InvokeWithInputAndConfig(id Identifier, input []Data, config configuration.Configuration) ([]Data, error)

	GetAnalytics() analytics.Analytics
	GetNetworkAccess() networking.NetworkAccess
	GetConfiguration() configuration.Configuration
	SetLogger(logger *zerolog.Logger)
	SetConfiguration(config configuration.Configuration)
	GetLogger() *zerolog.Logger
	GetUserInterface() ui.UserInterface
	SetUserInterface(ui ui.UserInterface)
}

Engine is the interface that wraps the methods that are used to manage workflows.

func NewDefaultWorkFlowEngine

func NewDefaultWorkFlowEngine() Engine

NewDefaultWorkFlowEngine is an implementation of the Engine interface.

func NewWorkFlowEngine

func NewWorkFlowEngine(configuration configuration.Configuration) Engine

NewWorkFlowEngine is an implementation of the Engine interface. It is called when creating a new app engine via CreateAppEngine().

type EngineImpl

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

EngineImpl is the default implementation of the Engine interface.

func (*EngineImpl) AddExtensionInitializer

func (e *EngineImpl) AddExtensionInitializer(initializer ExtensionInit)

AddExtensionInitializer adds an extension initializer to the engine.

func (*EngineImpl) GetAnalytics

func (e *EngineImpl) GetAnalytics() analytics.Analytics

GetAnalytics returns the analytics object.

func (*EngineImpl) GetConfiguration

func (e *EngineImpl) GetConfiguration() configuration.Configuration

GetConfiguration returns the configuration object.

func (*EngineImpl) GetLogger

func (e *EngineImpl) GetLogger() *zerolog.Logger

func (*EngineImpl) GetNetworkAccess

func (e *EngineImpl) GetNetworkAccess() networking.NetworkAccess

GetNetworkAccess returns the network access object.

func (*EngineImpl) GetUserInterface

func (e *EngineImpl) GetUserInterface() ui.UserInterface

func (*EngineImpl) GetWorkflow

func (e *EngineImpl) GetWorkflow(id Identifier) (Entry, bool)

GetWorkflow returns the workflow entry for the given workflow identifier.

func (*EngineImpl) GetWorkflows

func (e *EngineImpl) GetWorkflows() []Identifier

GetWorkflows returns a list of all registered workflows.

func (*EngineImpl) Init

func (e *EngineImpl) Init() error

Init initializes the engine by setting up the necessary defaults.

func (*EngineImpl) Invoke

func (e *EngineImpl) Invoke(id Identifier) ([]Data, error)

Invoke invokes the workflow with the given identifier.

func (*EngineImpl) InvokeWithConfig

func (e *EngineImpl) InvokeWithConfig(id Identifier, config configuration.Configuration) ([]Data, error)

InvokeWithConfig invokes the workflow with the given identifier and configuration.

func (*EngineImpl) InvokeWithInput

func (e *EngineImpl) InvokeWithInput(id Identifier, input []Data) ([]Data, error)

InvokeWithInput invokes the workflow with the given identifier and input data.

func (*EngineImpl) InvokeWithInputAndConfig

func (e *EngineImpl) InvokeWithInputAndConfig(
	id Identifier,
	input []Data,
	config configuration.Configuration,
) ([]Data, error)

InvokeWithInputAndConfig invokes the workflow with the given identifier, input data and configuration.

func (*EngineImpl) Register

func (e *EngineImpl) Register(id Identifier, config ConfigurationOptions, entryPoint Callback) (Entry, error)

Register registers a new workflow entry with the engine. In order to register a workflow, the following parameters are required: - id: the workflow identifier - config: the configuration options for the workflow - entryPoint: the entry point function for the workflow

func (*EngineImpl) SetConfiguration

func (e *EngineImpl) SetConfiguration(config configuration.Configuration)

func (*EngineImpl) SetLogger

func (e *EngineImpl) SetLogger(logger *zerolog.Logger)

func (*EngineImpl) SetUserInterface

func (e *EngineImpl) SetUserInterface(userInterface ui.UserInterface)

type Entry

type Entry interface {
	GetEntryPoint() Callback
	GetConfigurationOptions() ConfigurationOptions
	IsVisible() bool
	SetVisibility(visible bool)
}

Entry is an interface that wraps the methods that are used to manage workflow entries.

type EntryImpl

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

EntryImpl is the default implementation of the Entry interface.

func (*EntryImpl) GetConfigurationOptions

func (e *EntryImpl) GetConfigurationOptions() ConfigurationOptions

GetConfigurationOptions returns the configuration options for the workflow entry.

func (*EntryImpl) GetEntryPoint

func (e *EntryImpl) GetEntryPoint() Callback

GetEntryPoint returns the entry point callback for the workflow entry.

func (*EntryImpl) IsVisible

func (e *EntryImpl) IsVisible() bool

IsVisible returns true if the workflow entry is visible.

func (*EntryImpl) SetVisibility

func (e *EntryImpl) SetVisibility(visible bool)

SetVisibility sets the visibility of the workflow entry.

type ExtensionInit

type ExtensionInit func(engine Engine) error

type Identifier

type Identifier = *url.URL

typedefs

func NewTypeIdentifier

func NewTypeIdentifier(workflowID Identifier, dataType string) Identifier

NewTypeIdentifier creates a new type identifier represented in parsed URL format. It accepts a workflow identifier and a data type string which is used as the path part of the URL.

func NewWorkflowIdentifier

func NewWorkflowIdentifier(command string) Identifier

NewWorkflowIdentifier creates a new workflow identifier represented in parsed URL format. It accepts a command param which is converted to a dot separated string and used as the host part of the URL.

type InvocationContext

type InvocationContext interface {
	GetWorkflowIdentifier() Identifier
	GetConfiguration() configuration.Configuration
	GetEngine() Engine
	GetAnalytics() analytics.Analytics
	GetNetworkAccess() networking.NetworkAccess
	GetLogger() *log.Logger
	GetEnhancedLogger() *zerolog.Logger
	GetUserInterface() ui.UserInterface
}

InvocationContext is an interface that wraps various context information that is passed to a workflow when it is invoked.

func NewInvocationContext

func NewInvocationContext(
	id Identifier,
	config configuration.Configuration,
	engine Engine,
	network networking.NetworkAccess,
	logger zerolog.Logger,
	analyticsImpl analytics.Analytics,
	ui ui.UserInterface,
) InvocationContext

Jump to

Keyboard shortcuts

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