Documentation ¶
Index ¶
- Constants
- func LoadStateCount(dbp zesty.DBProvider, tags map[string]string) (sc map[string]float64, err error)
- func RegisterTaskTime(templateName string, taskCreation, resCreation time.Time)
- func RegisterValidationTime(templateName string, taskCreation time.Time)
- func RotateTasks(dbp zesty.DBProvider) (err error)
- type Batch
- type BatchDBModel
- type Comment
- type DBModel
- type ListFilter
- type StepError
- type Task
- func Create(dbp zesty.DBProvider, tt *tasktemplate.TaskTemplate, reqUsername string, ...) (t *Task, err error)
- func ListTasks(dbp zesty.DBProvider, filter ListFilter) (t []*Task, err error)
- func LoadFromID(dbp zesty.DBProvider, ID int64) (t *Task, err error)
- func LoadFromPublicID(dbp zesty.DBProvider, publicID string) (t *Task, err error)
- func LoadLockedFromPublicID(dbp zesty.DBProvider, publicID string) (t *Task, err error)
- func (t *Task) Delete(dbp zesty.DBProvider) (err error)
- func (t *Task) ExportTaskInfos(values *values.Values)
- func (t *Task) NotifyStepState(stepName, stepState string)
- func (t *Task) NotifyValidationRequired(tt *tasktemplate.TaskTemplate)
- func (t *Task) SetInput(input map[string]interface{})
- func (t *Task) SetResult(values *values.Values) error
- func (t *Task) SetState(s string)
- func (t *Task) SetTags(tags map[string]string, values *values.Values) error
- func (t *Task) SetWatcherGroups(watcherGroups []string)
- func (t *Task) SetWatcherUsernames(watcherUsernames []string)
- func (t *Task) Update(dbp zesty.DBProvider, skipValidation, recordLastActivity bool) (err error)
- func (t *Task) Valid(tt *tasktemplate.TaskTemplate) error
Constants ¶
const ( StateRunning = "RUNNING" StateDone = "DONE" StateTODO = "TODO" // default on creation StateBlocked = "BLOCKED" // not automatically retriable, 400 bad requests, etc.. StateCancelled = "CANCELLED" StateWontfix = "WONTFIX" StateWaiting = "WAITING" )
possible task states
Variables ¶
This section is empty.
Functions ¶
func LoadStateCount ¶
func LoadStateCount(dbp zesty.DBProvider, tags map[string]string) (sc map[string]float64, err error)
LoadStateCount returns a map containing the count of tasks grouped by state
func RegisterTaskTime ¶ added in v1.10.0
RegisterTaskTime computes the execution duration and the complete duration (from creation to completion) of a task. These metrics are then pushed to Prometheus.
func RegisterValidationTime ¶ added in v1.10.0
RegisterValidationTime computes the duration between the task creation and the associated resolution's creation. This metric is then pushed to Prometheus.
func RotateTasks ¶
func RotateTasks(dbp zesty.DBProvider) (err error)
RotateTasks loads all tasks stored in DB and makes sure that their cyphered content has been handled with the latest available storage key
Types ¶
type Batch ¶
type Batch struct {
BatchDBModel
}
Batch represents a group of tasks, created under a common identifier
func CreateBatch ¶
func CreateBatch(dbp zesty.DBProvider) (b *Batch, err error)
CreateBatch inserts a new batch in DB
func LoadBatchFromPublicID ¶
func LoadBatchFromPublicID(dbp zesty.DBProvider, publicID string) (b *Batch, err error)
LoadBatchFromPublicID returns a task batch, loaded from DB given its ID
type BatchDBModel ¶
BatchDBModel is a Batch's representation in DB
type Comment ¶
type Comment struct { ID int64 `json:"-" db:"id"` PublicID string `json:"id" db:"public_id"` TaskID int64 `json:"-" db:"id_task"` Username string `json:"username" db:"username"` Created time.Time `json:"created" db:"created"` Updated time.Time `json:"updated" db:"updated"` Content string `json:"content" db:"content"` }
Comment is the structure representing a comment made on a task
func CreateComment ¶
CreateComment inserts a new comment in DB
func LoadCommentFromPublicID ¶
func LoadCommentFromPublicID(dbp zesty.DBProvider, publicID string) (c *Comment, err error)
LoadCommentFromPublicID returns a single comment, given its ID
func LoadCommentsFromTaskID ¶
func LoadCommentsFromTaskID(dbp zesty.DBProvider, taskID int64) (c []*Comment, err error)
LoadCommentsFromTaskID returns the list of comments related to a task
func (*Comment) Delete ¶
func (c *Comment) Delete(dbp zesty.DBProvider) (err error)
Delete removes a comment from DB
type DBModel ¶
type DBModel struct { ID int64 `json:"-" db:"id"` PublicID string `json:"id" db:"public_id"` Title string `json:"title" db:"title"` TemplateID int64 `json:"-" db:"id_template"` BatchID *int64 `json:"-" db:"id_batch"` RequesterUsername string `json:"requester_username" db:"requester_username"` RequesterGroups []string `json:"requester_groups,omitempty" db:"requester_groups"` WatcherUsernames []string `json:"watcher_usernames,omitempty" db:"watcher_usernames"` WatcherGroups []string `json:"watcher_groups,omitempty" db:"watcher_groups"` ResolverUsernames []string `json:"resolver_usernames,omitempty" db:"resolver_usernames"` ResolverGroups []string `json:"resolver_groups,omitempty" db:"resolver_groups"` Created time.Time `json:"created" db:"created"` State string `json:"state" db:"state"` StepsDone int `json:"steps_done" db:"steps_done"` StepsTotal int `json:"steps_total" db:"steps_total"` LastActivity time.Time `json:"last_activity" db:"last_activity"` Tags map[string]string `json:"tags,omitempty" db:"tags"` CryptKey []byte `json:"-" db:"crypt_key"` // key for encrypting steps (itself encrypted with master key) EncryptedInput []byte `json:"-" db:"encrypted_input"` EncryptedResult []byte `json:"-" db:"encrypted_result"` // encrypted Result }
DBModel is the "strict" representation of a task in DB, as expressed in SQL schema
type ListFilter ¶
type ListFilter struct { RequesterUser *string PotentialResolverUser *string PotentialResolverGroups []string RequesterOrPotentialResolverUser *string RequesterOrPotentialResolverGroups []string Last *string State *string Batch *Batch PageSize uint64 Before *time.Time After *time.Time Tags map[string]string Template *string }
ListFilter holds parameters for filtering a list of tasks
type Task ¶
type Task struct { DBModel TemplateName string `json:"template_name" db:"template_name"` Input map[string]interface{} `json:"input" db:"-"` Result map[string]interface{} `json:"result,omitempty" db:"-"` ResultStr string `json:"-" db:"-"` Resolution *string `json:"resolution,omitempty" db:"resolution_public_id"` LastStart *time.Time `json:"last_start,omitempty" db:"last_start"` LastStop *time.Time `json:"last_stop,omitempty" db:"last_stop"` ResolverUsername *string `json:"resolver_username,omitempty" db:"resolver_username"` Comments []*Comment `json:"comments,omitempty" db:"-"` Batch *string `json:"batch,omitempty" db:"batch_public_id"` Errors []StepError `json:"errors,omitempty" db:"-"` ResolverInputs []input.Input `json:"resolver_inputs,omitempty" db:"resolver_inputs"` }
Task is the full representation of a requested process on µTask A task is necessarily derived from a template, the formal description of the process to be executed, plus inputs provided by the requester The execution of the task will be handled through another structure, its resolution When the resolution is finalized, results will be committed back to the Task structure Comments can be added to a task, by all parties involved (requester and resolver) A task can be made visible to third parties by adding their usernames to the watcher_usernames list
func Create ¶
func Create(dbp zesty.DBProvider, tt *tasktemplate.TaskTemplate, reqUsername string, reqGroups []string, watcherUsernames []string, watcherGroups []string, resolverUsernames []string, resolverGroups []string, input map[string]interface{}, tags map[string]string, b *Batch) (t *Task, err error)
Create inserts a new Task in DB
func ListTasks ¶
func ListTasks(dbp zesty.DBProvider, filter ListFilter) (t []*Task, err error)
ListTasks returns a list of tasks, optionally filtered on one or several criteria
func LoadFromID ¶
func LoadFromID(dbp zesty.DBProvider, ID int64) (t *Task, err error)
LoadFromID returns a single task, given its "private" ID only used internally, this ID is not exposed through µTask's API
func LoadFromPublicID ¶
func LoadFromPublicID(dbp zesty.DBProvider, publicID string) (t *Task, err error)
LoadFromPublicID returns a single task, given its public ID
func LoadLockedFromPublicID ¶
func LoadLockedFromPublicID(dbp zesty.DBProvider, publicID string) (t *Task, err error)
LoadLockedFromPublicID returns a single task, given its ID, locked for an update transaction, so that only one instance of µTask can make a claim on it and avoid collisions with other instances
func (*Task) Delete ¶
func (t *Task) Delete(dbp zesty.DBProvider) (err error)
Delete removes a task from DB
func (*Task) ExportTaskInfos ¶
ExportTaskInfos records task-specific data to a Values structure
func (*Task) NotifyStepState ¶ added in v1.13.0
func (*Task) NotifyValidationRequired ¶ added in v1.13.0
func (t *Task) NotifyValidationRequired(tt *tasktemplate.TaskTemplate)
func (*Task) SetResult ¶
SetResult consolidates values collected during resolution into the task's final result
func (*Task) SetWatcherGroups ¶ added in v1.19.0
SetWatcherGroups sets the list of watcher groups for the task
func (*Task) SetWatcherUsernames ¶
SetWatcherUsernames sets the list of watchers for the task
func (*Task) Update ¶
func (t *Task) Update(dbp zesty.DBProvider, skipValidation, recordLastActivity bool) (err error)
Update commits changes to a task's state to DB A flag allows to skip validation: only exposed internally for special situations, where a task could be out of sync with its template
func (*Task) Valid ¶
func (t *Task) Valid(tt *tasktemplate.TaskTemplate) error
Valid asserts that the task holds valid data: the state is among accepted states, and input is present and valid given the template spec