Documentation
¶
Index ¶
- Constants
- Variables
- func AuthoriseTopic(ctx context.Context, schema *proto.Schema, topic *proto.Task) (bool, error)
- func AuthorisedTopics(ctx context.Context, schema *proto.Schema) ([]*proto.Task, error)
- type Metrics
- type Stats
- type Status
- type Task
- func AssignTask(ctx context.Context, pbTask *proto.Task, id string, ...) (task *Task, err error)
- func CompleteTask(ctx context.Context, pbTask *proto.Task, id string, identityID string) (task *Task, err error)
- func CreateTask(ctx context.Context, pbTask *proto.Task, identityID string, ...) (task *Task, err error)
- func DeferTask(ctx context.Context, pbTask *proto.Task, id string, deferUntil time.Time, ...) (task *Task, err error)
- func GetTaskQueue(ctx context.Context, pbTask *proto.Task, inputs map[string]any) (tasks []*Task, err error)
- func NextTask(ctx context.Context, pbTask *proto.Task, identityID string) (task *Task, err error)
- func StartTask(ctx context.Context, pbTask *proto.Task, id string) (task *Task, err error)
- type TaskStatus
- type Topic
Constants ¶
const EntityFieldNameTaskID string = "keel_task_id"
EntityFieldNameTaskID is the field name used in the entity table to link to a keel task.
Variables ¶
var ErrTaskNotFound = errors.New("task not found")
Functions ¶
func AuthoriseTopic ¶
AuthoriseTopic will check that the context's identity is authorised to access the given topic in the context of the given schema.
Types ¶
type Stats ¶
type Stats struct {
OpenCount int `json:"openCount"`
AssignedCount int `json:"assignedCount"`
DeferredCount int `json:"deferredCount"`
CompletionRate float32 `json:"completionRate"`
CompletionTimeMedian *time.Duration `json:"completionTimeMedian,omitempty"`
CompletionTime90 *time.Duration `json:"completionTime90P,omitempty"`
CompletionTime99 *time.Duration `json:"completionTime99P,omitempty"`
}
type Task ¶
type Task struct {
ID string `gorm:"column:id;primaryKey;->" json:"id"`
Name string `gorm:"column:name" json:"name"`
Status Status `gorm:"column:status" json:"status"`
FlowRunID *string `gorm:"column:flow_run_id" json:"flowRunId,omitempty"`
CreatedAt time.Time `gorm:"column:created_at;->" json:"createdAt"`
UpdatedAt time.Time `gorm:"column:updated_at;->" json:"updatedAt"`
AssignedTo *string `gorm:"column:assigned_to" json:"assignedTo,omitempty"`
AssignedAt *time.Time `gorm:"column:assigned_at" json:"assignedAt,omitempty"`
ResolvedAt *time.Time `gorm:"column:resolved_at" json:"resolvedAt,omitempty"`
DeferredUntil *time.Time `gorm:"column:deferred_until" json:"deferredUntil,omitempty"`
}
func AssignTask ¶
func AssignTask(ctx context.Context, pbTask *proto.Task, id string, assignedTo, identityID string) (task *Task, err error)
AssignTask marks the given task as assigned to the given identity and returns it.
func CompleteTask ¶
func CompleteTask(ctx context.Context, pbTask *proto.Task, id string, identityID string) (task *Task, err error)
CompleteTask marks the given task as completed and returns it.
func CreateTask ¶
func CreateTask(ctx context.Context, pbTask *proto.Task, identityID string, deferUntil *time.Time, data map[string]any) (task *Task, err error)
CreateTask creates a new task and returns it.
func DeferTask ¶
func DeferTask(ctx context.Context, pbTask *proto.Task, id string, deferUntil time.Time, identityID string) (task *Task, err error)
DeferTask marks the given task as deferred until the given date and returns it.
func GetTaskQueue ¶
func GetTaskQueue(ctx context.Context, pbTask *proto.Task, inputs map[string]any) (tasks []*Task, err error)
GetTaskQueue returns the ordered queue of tasks for a given topic.
func NextTask ¶
NextTask will assign and return the next available task to the authenticated identity.
type TaskStatus ¶
type TaskStatus struct {
ID string `gorm:"column:id;primaryKey;->" json:"id"`
TaskID string `gorm:"column:keel_task_id" json:"taskId"`
Status Status `gorm:"column:status" json:"status"`
AssignedTo *string `gorm:"column:assigned_to" json:"assignedTo,omitempty"`
SetBy string `gorm:"column:set_by" json:"setBy"`
CreatedAt time.Time `gorm:"column:created_at;->" json:"createdAt"`
}
TaskStatus represents a log of status updates for a particular task.
func (TaskStatus) TableName ¶
func (TaskStatus) TableName() string