Documentation ¶
Index ¶
- Constants
- func RotateResolutions(dbp zesty.DBProvider) (err error)
- type DBModel
- type Resolution
- func Create(dbp zesty.DBProvider, t *task.Task, resolverInputs map[string]interface{}, ...) (r *Resolution, err error)
- func ListResolutions(dbp zesty.DBProvider, t *task.Task, resolverUsername *string, state *string, ...) (r []*Resolution, err error)
- func LoadFromPublicID(dbp zesty.DBProvider, publicID string) (*Resolution, error)
- func LoadLockedFromPublicID(dbp zesty.DBProvider, publicID string) (*Resolution, error)
- func LoadLockedNoWaitFromPublicID(dbp zesty.DBProvider, publicID string) (*Resolution, error)
- func (r *Resolution) BuildStepTree()
- func (r *Resolution) ClearOutputs()
- func (r *Resolution) Delete(dbp zesty.DBProvider) (err error)
- func (r *Resolution) ExtendRunMax(i int)
- func (r *Resolution) IncrementRunCount()
- func (r *Resolution) SetInput(input map[string]interface{})
- func (r *Resolution) SetInstanceID(id uint64)
- func (r *Resolution) SetLastStart(t time.Time)
- func (r *Resolution) SetLastStop(t time.Time)
- func (r *Resolution) SetNextRetry(t time.Time)
- func (r *Resolution) SetState(state string)
- func (r *Resolution) SetStep(name string, s *step.Step)
- func (r *Resolution) SetStepState(stepName, state string)
- func (r *Resolution) Update(dbp zesty.DBProvider) (err error)
Constants ¶
const ( StateRunning = "RUNNING" StateDone = "DONE" StateCancelled = "CANCELLED" StateTODO = "TODO" // default on creation StatePaused = "PAUSED" // pause execution in order to make safe updates StateBlockedToCheck = "BLOCKED_TOCHECK" // blocked by a crash, needs human intervention StateBlockedBadRequest = "BLOCKED_BADREQUEST" // blocked by client error, bad input, etc.. StateBlockedDeadlock = "BLOCKED_DEADLOCK" // blocked by unsolvable dependencies StateBlockedMaxRetries = "BLOCKED_MAXRETRIES" // has reached max retries, still failing StateBlockedFatal = "BLOCKED_FATAL" // encountered a fatal non-client error StateWaiting = "WAITING" StateCrashed = "CRASHED" StateRetry = "RETRY" StateError = "ERROR" // a step failed, we'll retry, keep the resolution running StateToAutorun = "TO_AUTORUN" StateToAutorunDelayed = "TO_AUTORUN_DELAYED" StateAutorunning = "AUTORUNNING" )
all valid resolution states
Variables ¶
This section is empty.
Functions ¶
func RotateResolutions ¶
func RotateResolutions(dbp zesty.DBProvider) (err error)
RotateResolutions loads all resolutions stored in DB and makes sure that their cyphered content has been handled with the latest available storage key
Types ¶
type DBModel ¶
type DBModel struct { ID int64 `json:"-" db:"id"` PublicID string `json:"id" db:"public_id"` TaskID int64 `json:"-" db:"id_task"` ResolverUsername string `json:"resolver_username" db:"resolver_username"` State string `json:"state" db:"state"` InstanceID *uint64 `json:"instance_id,omitempty" db:"instance_id"` Created time.Time `json:"created,omitempty" db:"created"` LastStart *time.Time `json:"last_start,omitempty" db:"last_start"` LastStop *time.Time `json:"last_stop,omitempty" db:"last_stop"` NextRetry *time.Time `json:"next_retry,omitempty" db:"next_retry"` RunCount int `json:"run_count" db:"run_count"` RunMax int `json:"run_max" db:"run_max"` CryptKey []byte `json:"-" db:"crypt_key"` // key for encrypting steps (itself encrypted with master key) EncryptedInput []byte `json:"-" db:"encrypted_resolver_input"` EncryptedSteps []byte `json:"-" db:"encrypted_steps"` // encrypted Steps map BaseConfigurations map[string]json.RawMessage `json:"base_configurations" db:"base_configurations"` }
DBModel is a resolution's representation in DB
type Resolution ¶
type Resolution struct { DBModel TaskPublicID string `json:"task_id" db:"task_public_id"` TaskTitle string `json:"task_title" db:"task_title"` Values *values.Values `json:"-" db:"-"` // never persisted: rebuilt on instantiation Steps map[string]*step.Step `json:"steps,omitempty" db:"-"` // persisted in encrypted blob ResolverInput map[string]interface{} `json:"resolver_inputs,omitempty" db:"-"` // persisted in encrypted blob StepTreeIndex map[string][]string `json:"-" db:"-"` StepTreeIndexPrune map[string][]string `json:"-" db:"-"` StepList []string `json:"-" db:"-"` ForeachChildrenAlreadyContracted map[string]bool `json:"-" db:"-"` }
Resolution is the full representation of a task's resolution process composed from data from "resolution" table and "task" table All intermediary state of execution will be held by this structure
func Create ¶
func Create(dbp zesty.DBProvider, t *task.Task, resolverInputs map[string]interface{}, resUser string, autorun bool, delayedUntil *time.Time) (r *Resolution, err error)
Create inserts a new resolution in DB
func ListResolutions ¶
func ListResolutions(dbp zesty.DBProvider, t *task.Task, resolverUsername *string, state *string, instanceID *uint64, pageSize uint64, last *string) (r []*Resolution, err error)
ListResolutions returns a collection of existing task resolutions optionally filtered by task, resolver username, state or instance ID a page size can be passed to limit the size of the collection, and also a pointer to the previous page's last element
func LoadFromPublicID ¶
func LoadFromPublicID(dbp zesty.DBProvider, publicID string) (*Resolution, error)
LoadFromPublicID returns a single task resolution given its public ID
func LoadLockedFromPublicID ¶
func LoadLockedFromPublicID(dbp zesty.DBProvider, publicID string) (*Resolution, error)
LoadLockedFromPublicID returns a single task resolution given its public ID while acquiring a lock on its DB row, to ensure only this instance keeps access to it until the surrounding transaction is done (ensure that only this instance of µTask collects this resolution for execution). If another instance already has a lock, it will wait until the other instance release it.
func LoadLockedNoWaitFromPublicID ¶ added in v1.4.0
func LoadLockedNoWaitFromPublicID(dbp zesty.DBProvider, publicID string) (*Resolution, error)
LoadLockedNoWaitFromPublicID returns a single task resolution given its public ID while acquiring a lock on its DB row, to ensure only this instance keeps access to it until the surrounding transaction is done (ensure that only this instance of µTask collects this resolution for execution). If another instance already has a lock, it will directly return an error.
func (*Resolution) BuildStepTree ¶
func (r *Resolution) BuildStepTree()
BuildStepTree re-generates a dependency graph for the steps useful for determining elligibility of any given step for execution
func (*Resolution) ClearOutputs ¶
func (r *Resolution) ClearOutputs()
ClearOutputs empties the sensitive content of steps -> renders a simplified view of a resolution
func (*Resolution) Delete ¶
func (r *Resolution) Delete(dbp zesty.DBProvider) (err error)
Delete removes the Resolution from DB
func (*Resolution) ExtendRunMax ¶
func (r *Resolution) ExtendRunMax(i int)
ExtendRunMax adds an arbitraty amount to the number of allowed executions for the resolution
func (*Resolution) IncrementRunCount ¶
func (r *Resolution) IncrementRunCount()
IncrementRunCount records that a new execution has been performed for this resolution incrementing the total count of executions (relevant to keep track of RunCount < MaxRetries)
func (*Resolution) SetInput ¶
func (r *Resolution) SetInput(input map[string]interface{})
SetInput stores the inputs provided by the task's resolver
func (*Resolution) SetInstanceID ¶
func (r *Resolution) SetInstanceID(id uint64)
SetInstanceID assigns an instance ID to the Resolution In other words, the current running instance of µTask 'acquires' this resolution, ensuring that other instances will not perform conflicting work on the Resolution
func (*Resolution) SetLastStart ¶
func (r *Resolution) SetLastStart(t time.Time)
SetLastStart records the last time an execution cycle began
func (*Resolution) SetLastStop ¶
func (r *Resolution) SetLastStop(t time.Time)
SetLastStop records the last time an execution cycle ended
func (*Resolution) SetNextRetry ¶
func (r *Resolution) SetNextRetry(t time.Time)
SetNextRetry assigns a point in time when the resolution will become eligible for execution
func (*Resolution) SetState ¶
func (r *Resolution) SetState(state string)
SetState changes the Resolution's state
func (*Resolution) SetStep ¶
func (r *Resolution) SetStep(name string, s *step.Step)
SetStep re-assigns a named step, with its updated state and data
func (*Resolution) SetStepState ¶ added in v1.6.0
func (r *Resolution) SetStepState(stepName, state string)
func (*Resolution) Update ¶
func (r *Resolution) Update(dbp zesty.DBProvider) (err error)
Update commits any changes of state in Resolution to DB