actions

package
v4.4.8-alpha1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package actions provides interfaces to manage tasks and provides default implementation for common actions.

Action are registered by ID during the init phase of each actions' subfolder

Index

Constants

View Source
const (
	ActionCategoryTree      = "01 - Files/Folders Operations"
	ActionCategoryArchives  = "02 - Archives Operations"
	ActionCategoryScheduler = "03 - Scheduler Tools / Internals"
	ActionCategoryPutGet    = "04 - Upload/Download to External Servers"
	ActionCategoryCmd       = "05 - Atomic Commands and Scripts"
	ActionCategoryContents  = "06 - Contents Processing"
	ActionCategoryIDM       = "07 - Identity Management"
	ActionCategoryNotify    = "08 - Notifications and Emails"
	ActionCategoryETL       = "09 - Extract/Load/Transform"
)

Variables

View Source
var CategoryTints = map[string]string{
	ActionCategoryTree:      "#03a9f4",
	ActionCategoryArchives:  "#fbc02d",
	ActionCategoryScheduler: "#009688",
	ActionCategoryPutGet:    "#4caf50",
	ActionCategoryCmd:       "#795548",
	ActionCategoryContents:  "#f44336",
	ActionCategoryIDM:       "#438db3",
	ActionCategoryNotify:    "#ff9800",
	ActionCategoryETL:       "#009688",
}
View Source
var (
	IgnoredActionName = "$action.internal.ignored$"
)

Functions

This section is empty.

Types

type ActionDescription

type ActionDescription struct {
	ID                string
	Label             string
	Icon              string
	IsInternal        bool
	Description       string
	Category          string
	Tint              string
	InputDescription  string
	OutputDescription string
	SummaryTemplate   string
	HasForm           bool
	FormModule        string
	FormModuleProps   string
}

type ActionsManager

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

func GetActionsManager

func GetActionsManager() *ActionsManager

GetActionsManager provides global access to the default action manager.

func (*ActionsManager) ActionById

func (m *ActionsManager) ActionById(actionId string) (ConcreteAction, bool)

func (*ActionsManager) DescribeActions

func (m *ActionsManager) DescribeActions(languages ...string) map[string]ActionDescription

DescribeActions provides a list of all registered actions

func (*ActionsManager) LoadActionForm

func (m *ActionsManager) LoadActionForm(actionID string) (*forms.Form, error)

LoadActionForm tries to load a forms.Form object that can be serialized for frontend

func (*ActionsManager) Register

func (m *ActionsManager) Register(name string, a Concrete)

type Concrete

type Concrete func() ConcreteAction

type ConcreteAction

type ConcreteAction interface {
	common.RuntimeProvider
	// GetName returns a unique identifier
	GetName() string
	// Init initialize parameters
	Init(job *jobs.Job, action *jobs.Action) error
	// Run performs the actual action code
	Run(ctx context.Context, channels *RunnableChannels, input *jobs.ActionMessage) (*jobs.ActionMessage, error)
}

ConcreteAction is the base interface for pydio actions. All actions must implement this interface.

type ControllableAction

type ControllableAction interface {
	CanPause() bool
	CanStop() bool
}

ControllableAction Actions that implement this interface can eventually be stopped and/or paused+resumed

type DescriptionProviderAction

type DescriptionProviderAction interface {
	GetDescription(lang ...string) ActionDescription
	GetParametersForm() *forms.Form
}

DescriptionProviderAction has a human-readable label

type ProgressProviderAction

type ProgressProviderAction interface {
	ProvidesProgress() bool
}

ProgressProviderAction Actions that implement this interface will publish progress updates on the progress channel.

type RecursiveNodeWalkerAction

type RecursiveNodeWalkerAction interface {
	SetNodeFilterAsWalkFilter(*jobs.NodesSelector)
}

RecursiveNodeWalkerAction Actions that implement this interface may perform some recursive nodes listing internally. If the action definition has a NodeFilter set, pass this along to the running instance to filter nodes on the go.

type RunnableChannels

type RunnableChannels struct {
	// Input Channels
	Pause  chan interface{}
	Resume chan interface{}
	// Output Channels
	Status    chan jobs.TaskStatus
	StatusMsg chan string
	Progress  chan float32
}

RunnableChannels defines the API to communicate with a Runnable via Channels

func (*RunnableChannels) BlockUntilResume

func (r *RunnableChannels) BlockUntilResume(ctx context.Context, maxPauseTime ...time.Duration) chan interface{}

BlockUntilResume returns a blocking channel that can be inserted anywhere to block execution

func (*RunnableChannels) WrapReader added in v4.0.6

func (r *RunnableChannels) WrapReader(readerOrCloser io.Reader, targetSize int64) io.ReadCloser

WrapReader wraps a reader (or a readCloser) into an io.ReadCloser and publishes the progress on the channels.Progress

type TaskParameter added in v4.3.1

type TaskParameter struct {
	*forms.FormField
	// contains filtered or unexported fields
}

TaskParameter encapsulates a form parameter and its value at runtime. There are three modes :

  • Basic types (FormField) always pass values as string (to be evaluated)
  • Replicable Fields may find 0 or N occurrences of a map[string]*TaskParameter
  • SwitchField has a switch value and corresponding set of subvalues as map[string]*TaskParameter

func (*TaskParameter) Bool added in v4.3.1

func (f *TaskParameter) Bool(ctx context.Context, input *jobs.ActionMessage) (bool, error)

func (*TaskParameter) Int added in v4.3.1

func (f *TaskParameter) Int(ctx context.Context, input *jobs.ActionMessage) (int, error)

func (*TaskParameter) Int64 added in v4.3.1

func (f *TaskParameter) Int64(ctx context.Context, input *jobs.ActionMessage) (int64, error)

func (*TaskParameter) IsMultiple added in v4.3.1

func (f *TaskParameter) IsMultiple() bool

func (*TaskParameter) IsSwitch added in v4.3.1

func (f *TaskParameter) IsSwitch() bool

func (*TaskParameter) MustBool added in v4.3.1

func (f *TaskParameter) MustBool(ctx context.Context, input *jobs.ActionMessage) bool

func (*TaskParameter) MustInt added in v4.3.1

func (f *TaskParameter) MustInt(ctx context.Context, input *jobs.ActionMessage) int

func (*TaskParameter) MustInt64 added in v4.3.1

func (f *TaskParameter) MustInt64(ctx context.Context, input *jobs.ActionMessage) int64

func (*TaskParameter) Occurrences added in v4.3.1

func (f *TaskParameter) Occurrences() (oo []*TaskParameters)

Occurrences returns a slice of TaskParameters, each one containing the map of TaskParameter

func (*TaskParameter) Raw added in v4.3.1

func (f *TaskParameter) Raw() string

Raw returns the raw value as string

func (*TaskParameter) String added in v4.3.1

func (f *TaskParameter) String(ctx context.Context, input *jobs.ActionMessage) string

func (*TaskParameter) SwitchValues added in v4.3.1

func (f *TaskParameter) SwitchValues() (string, *TaskParameters)

SwitchValues returns both the selected value and the sub form data as a TaskParameters container

type TaskParameters added in v4.3.1

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

TaskParameters encapsulates action.Parameters at runtime. Use it as a composable struct in ConcreteAction implementations Do not forget to call InitParameters at runtime.

func (*TaskParameters) Bool added in v4.3.1

func (p *TaskParameters) Bool(name string) (bool, error)

Bool evaluates underlying value to bool

func (*TaskParameters) Get added in v4.3.1

func (p *TaskParameters) Get(s string) *TaskParameter

Get returns a *TaskParameter for a specific key

func (*TaskParameters) InitParameters added in v4.3.1

func (p *TaskParameters) InitParameters(f *forms.Form, a *jobs.Action)

InitParameters MUST be called at action.Init

func (*TaskParameters) Int added in v4.3.1

func (p *TaskParameters) Int(name string) (int, error)

Int evaluates underlying value to int

func (*TaskParameters) Int64 added in v4.3.1

func (p *TaskParameters) Int64(name string) (int64, error)

Int64 evaluates underlying value to int64

func (*TaskParameters) MustBool added in v4.3.1

func (p *TaskParameters) MustBool(name string) bool

MustBool evaluates underlying value to bool without error checking

func (*TaskParameters) MustInt added in v4.3.1

func (p *TaskParameters) MustInt(name string) int

MustInt evaluates underlying value to int without error checking

func (*TaskParameters) MustInt64 added in v4.3.1

func (p *TaskParameters) MustInt64(name string) int64

MustInt64 evaluates underlying value to int64 without error checking

func (*TaskParameters) String added in v4.3.1

func (p *TaskParameters) String(name string) string

String evaluates underlying value to string

func (*TaskParameters) WithParametersRuntime added in v4.3.1

func (p *TaskParameters) WithParametersRuntime(ctx context.Context, input *jobs.ActionMessage)

WithParametersRuntime sets context and input message for further evaluations

type TaskUpdaterDelegateAction

type TaskUpdaterDelegateAction interface {
	SetTask(task *jobs.Task)
}

TaskUpdaterDelegateAction Actions that implement this interface can send their status updates to a parent task

Directories

Path Synopsis
Package archive provides implementation of actions to work with archive files.
Package archive provides implementation of actions to work with archive files.
Package cmd provides default implementation for command-line-like actions.
Package cmd provides default implementation for command-line-like actions.
Package images provides default implementation of image related tasks.
Package images provides default implementation of image related tasks.
Package scheduler provides default implementation for basic scheduler tasks.
Package scheduler provides default implementation for basic scheduler tasks.
Package tree provides default implementation for tree related tasks.
Package tree provides default implementation for tree related tasks.

Jump to

Keyboard shortcuts

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