task

package
v1.1.2-0...-d77c1f3 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunAll

func RunAll(ctx context.Context, registry Registry, actions []*Action) (bool, error)

RunAll runs all actions

Types

type Action

type Action struct {
	Action string `json:",omitempty"`
	When   *When  `json:",omitempty"`

	Meta    *activity.Meta         `json:",omitempty"`
	Request map[string]interface{} `json:",omitempty"`

	*Actions `json:",omitempty"`
	// contains filtered or unexported fields
}

Action represents route action

func NewAction

func NewAction(action string, req interface{}) (*Action, error)

NewAction creates a new action for supplied name, action

func NewActionFromURL

func NewActionFromURL(ctx context.Context, fs afs.Service, URL string) (action *Action, err error)

NewActionFromURL create a new actions from URL

func (Action) Clone

func (a Action) Clone() *Action

Clone clones actions

func (Action) Expand

func (a Action) Expand(root *stage.Process, expander data.Map) *Action

Expand creates a new expanded action with expander

func (*Action) Init

func (a *Action) Init(ctx context.Context, fs afs.Service) error

Init initialises action

func (Action) JobReference

func (a Action) JobReference() *bigquery.JobReference

JobReference returns a job reference

func (Action) RequestStringValue

func (a Action) RequestStringValue(key string) string

RequestStringValue returns request string value for supplied key

func (Action) RequestValue

func (a Action) RequestValue(key string) interface{}

RequestValue returns request value for supplied key

func (Action) ServiceRequest

func (a Action) ServiceRequest() interface{}

ServiceRequest returns a service request

func (*Action) SetRequest

func (a *Action) SetRequest(req interface{}) error

SetRequest set request for supplied req instance

type Actions

type Actions struct {
	Job       *bigquery.Job `json:",omitempty"`
	OnSuccess []*Action     `json:",omitempty"`
	OnFailure []*Action     `json:",omitempty"`
}

Actions represents actions

func NewActions

func NewActions(onSuccess, onFailure []*Action) *Actions

NewActions creates an actions

func (*Actions) AddOnFailure

func (a *Actions) AddOnFailure(actions ...*Action)

AddOnFailure adds on failure action

func (*Actions) AddOnSuccess

func (a *Actions) AddOnSuccess(actions ...*Action)

AddOnSuccess adds on sucess action

func (Actions) Clone

func (a Actions) Clone() *Actions

func (Actions) CloneOnFailure

func (a Actions) CloneOnFailure() *Actions

CloneOnFailure returns actions to run

func (*Actions) Expand

func (a *Actions) Expand(root *stage.Process, action string, sourceURIs []string) *Actions

Expand creates clone actions with expanded sources URLs

func (*Actions) FinalizeOnSuccess

func (a *Actions) FinalizeOnSuccess(actions ...*Action)

func (*Actions) Init

func (a *Actions) Init(ctx context.Context, fs afs.Service) error

Init initialises actions

func (Actions) IsEmpty

func (a Actions) IsEmpty() bool

IsEmpty returns is actions are empty

func (Actions) ToRun

func (a Actions) ToRun(err error, job *base.Job) []*Action

ToRun returns actions to run

type Registry

type Registry interface {
	Service(name string) (Service, error)

	RegisterService(name string, service Service)

	RegisterAction(name string, service *ServiceAction)

	Action(name string) (*ServiceAction, error)

	Actions(service string) []string
}

Registry represents services actions

func NewRegistry

func NewRegistry() Registry

NewRegistry returns a service action registry

type Response

type Response interface{}

Response represents generic response

func Run

func Run(ctx context.Context, registry Registry, action *Action) (Response, error)

Run execute supplied actions

func RunWithService

func RunWithService(ctx context.Context, registry Registry, serviceName string, request *Action) (Response, error)

RunWithService handlers service request or error

type Service

type Service interface {
	Run(ctx context.Context, request *Action) (Response, error)
}

Service represents tasks service

type ServiceAction

type ServiceAction struct {
	Service     string
	RequestType reflect.Type
}

ServiceAction represets service action

func NewServiceAction

func NewServiceAction(service string, request interface{}) *ServiceAction

NewServiceAction creates a service action

func (*ServiceAction) SetServiceRequest

func (a *ServiceAction) SetServiceRequest(action *Action) error

SetServiceRequest creates a new request

type When

type When struct {
	//Exists if specified action would run only when table exists
	Exists string `json:",omitempty"`
}

When conditional action exection

Jump to

Keyboard shortcuts

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