operation

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AzureDeploymentNameFinder added in v1.3.4

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

func NewAzureDeploymentNameFinder added in v1.3.4

func NewAzureDeploymentNameFinder(operation *Operation) (*AzureDeploymentNameFinder, error)

func (*AzureDeploymentNameFinder) FindUntilDone added in v1.3.4

func (finder *AzureDeploymentNameFinder) FindUntilDone(ctx context.Context) (string, error)

type Configure

type Configure func(i *model.InvokedOperation) error

configure the operation

type DeployStageOperationFactory added in v1.3.4

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

func NewDeployStageOperationFactory added in v1.3.4

func NewDeployStageOperationFactory(repository Repository) *DeployStageOperationFactory

func (*DeployStageOperationFactory) Create added in v1.3.4

create a new deploy stage operation for each stage associated to the parent

type DeployStageOperationMap added in v1.3.4

type DeployStageOperationMap map[uuid.UUID]*Operation

type DryRunFunc

this is so the dry run can be tested, detaching actual dry run implementation

type ExecuteOperationCommand added in v1.3.5

type ExecuteOperationCommand struct {
	OperationId uuid.UUID `json:"operationId"`
}

this represents the message (command) that is sent to the operator to be executed

remarks: this will be sent over the messaging infrastructure

type ExecutionContext

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

Context object for interacting with an operation execution

remarks: flyweight of an Operation

func (*ExecutionContext) Attribute

func (c *ExecutionContext) Attribute(key model.AttributeKey, v any) error

func (*ExecutionContext) Complete

func (c *ExecutionContext) Complete()

func (*ExecutionContext) Context

func (c *ExecutionContext) Context() context.Context

func (*ExecutionContext) Error

func (c *ExecutionContext) Error(err error)

func (*ExecutionContext) Failed

func (c *ExecutionContext) Failed() error

func (*ExecutionContext) IsExecutable added in v1.3.5

func (c *ExecutionContext) IsExecutable() ([]string, bool)

func (*ExecutionContext) Operation

func (c *ExecutionContext) Operation() *Operation

func (*ExecutionContext) Pending added in v1.3.5

func (c *ExecutionContext) Pending() error

func (*ExecutionContext) Retry

func (c *ExecutionContext) Retry() error

func (*ExecutionContext) Running

func (c *ExecutionContext) Running() error

func (*ExecutionContext) SaveChanges

func (c *ExecutionContext) SaveChanges() error

func (*ExecutionContext) Success

func (c *ExecutionContext) Success()

func (*ExecutionContext) Value

func (c *ExecutionContext) Value(v any) error

type Executor

type Executor interface {
	Execute(context ExecutionContext) error
}

Executor is the interface for the actual execution of a logically invoked operation from the API Requestor --> invoke this operation --> enqueue --> executor --> execute the operation

func NewExecutor

func NewExecutor(operation OperationFunc) Executor

default operations executor that executions the operation(s) in sequence with logging and default retry logic

remarks: if any of the operations return an error, the executor considers this a failure and will not execute

type FinderResponse added in v1.3.4

type FinderResponse struct {
	Name string
}

type Operation

type Operation struct {
	model.InvokedOperation
	// contains filtered or unexported fields
}

remarks: Invoked Operation decorator+visitor

func (*Operation) Attribute

func (o *Operation) Attribute(key model.AttributeKey, v any) error

func (*Operation) Complete

func (o *Operation) Complete() error

func (*Operation) Context

func (o *Operation) Context() context.Context

func (*Operation) Deployment

func (o *Operation) Deployment() *model.Deployment

provides access to latest instance of associated deployment

func (*Operation) Execute

func (o *Operation) Execute() error

executes the operation

func (*Operation) Failed

func (o *Operation) Failed() error

func (*Operation) Pending added in v1.3.5

func (o *Operation) Pending() error

func (*Operation) Retry

func (o *Operation) Retry() error

Attempts to trigger a retry of the operation, if the operation has a retriable state

func (*Operation) Running

func (o *Operation) Running() error

func (*Operation) SaveChanges

func (o *Operation) SaveChanges() error

func (*Operation) Schedule

func (o *Operation) Schedule() error

func (*Operation) Success

func (o *Operation) Success() error

func (*Operation) Task added in v1.3.5

func (o *Operation) Task(task OperationTask)

sets the operation's task function

func (*Operation) Value

func (o *Operation) Value(v any) error

type OperationError added in v1.3.4

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

func NewError added in v1.3.4

func NewError(operation *Operation) *OperationError

func (*OperationError) Error added in v1.3.4

func (e *OperationError) Error() string

type OperationFunc

type OperationFunc func(context ExecutionContext) error

a executable operation with an execution context

func WithLogging

func WithLogging(operation OperationFunc) OperationFunc

type OperationFuncProvider

type OperationFuncProvider interface {
	Get(operationType sdk.OperationType) (OperationTask, error)
}

type OperationManager added in v1.3.4

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

func CloneManager added in v1.3.4

func CloneManager(manager *OperationManager) *OperationManager

func NewManager added in v1.3.4

func NewManager(db *gorm.DB, scheduler Scheduler, notify hook.NotifyFunc) (*OperationManager, error)

constructor factory of operation service

func (*OperationManager) Context added in v1.3.4

func (manager *OperationManager) Context() context.Context

type OperationTask added in v1.3.5

type OperationTask interface {
	Run(context ExecutionContext) error
	Continue(context ExecutionContext) error
}

func NewOperationTask added in v1.3.5

func NewOperationTask(options OperationTaskOptions) OperationTask

type OperationTaskOptions added in v1.3.5

type OperationTaskOptions struct {
	Run      OperationFunc //default run function
	Continue OperationFunc //if the run is intereupted, this function will be invoked
}

Represents the task that the operation will perform

type OperationWatcher added in v1.3.4

type OperationWatcher interface {
	// watch the operation with the given operation id for completion
	// 	id: the operation id
	//
	Watch(id uuid.UUID, options OperationWatcherOptions) (threading.CancellationToken, error)
}

func NewWatcher added in v1.3.4

func NewWatcher(repository Repository) OperationWatcher

type OperationWatcherOptions added in v1.3.4

type OperationWatcherOptions struct {
	Condition func(operation model.InvokedOperation) bool // the condition to watch for
	Frequency time.Duration
}

type Repository

type Repository interface {
	New(operationType sdk.OperationType, configure Configure) (*Operation, error)
	First(id uuid.UUID) (*Operation, error)
	Any(id uuid.UUID) bool
	Provider(provider OperationFuncProvider) error
	WithContext(ctx context.Context)
}

Operation factory

func NewRepository

func NewRepository(manager *OperationManager, provider OperationFuncProvider) (Repository, error)

NewRepository creates a new operation repository appConfig: application configuration provider: operation function provider, optional if the operation is not going to be executed and you want to interact with the operation

type RepositoryFactory added in v1.3.4

type RepositoryFactory func() (Repository, error)

func NewRepositoryFactory added in v1.3.4

func NewRepositoryFactory(appConfig *config.AppConfig) RepositoryFactory

type RetriableError

type RetriableError struct {
	Err        error
	RetryAfter time.Duration
}

RetriableError is a custom error that contains a positive duration for the next retry

func (*RetriableError) Error

func (e *RetriableError) Error() string

Error returns error message and a Retry-After duration

type Scheduler added in v1.3.5

type Scheduler interface {
	Schedule(ctx context.Context, operationId uuid.UUID) error
}

func NewScheduler added in v1.3.5

func NewScheduler(sender messaging.MessageSender) (Scheduler, error)

func NewSchedulerFromConfig added in v1.3.5

func NewSchedulerFromConfig(appConfig *config.AppConfig) (Scheduler, error)

Jump to

Keyboard shortcuts

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