jw

package module
v0.0.0-...-d062e30 Latest Latest
Warning

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

Go to latest
Published: May 13, 2022 License: MIT Imports: 6 Imported by: 7

README

jw

A FAIRE.

Go Report Card Go Reference

Licence

MIT.


Copyright (c) 2021-2022 dune

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	ID             string                 `bson:"_id" json:"id"`
	Name           string                 `bson:"name" json:"name"`
	Namespace      string                 `bson:"namespace" json:"namespace"`
	Type           string                 `bson:"type" json:"type"`
	Origin         string                 `bson:"origin" json:"origin"`
	Priority       Priority               `bson:"priority" json:"priority"`
	Config         map[string]interface{} `bson:"config" json:"config"`
	Public         map[string]interface{} `bson:"public" json:"public"`
	Private        map[string]interface{} `bson:"private" json:"private"`
	RunAfter       time.Time              `bson:"run_after" json:"run_after"`
	Exclusive      bool                   `bson:"exclusive" json:"exclusive"`
	MaxOccurrences int                    `bson:"max_occurrences" json:"max_occurrences"`
	MaxAttempts    int                    `bson:"max_attempts" json:"max_attempts"`
	Category       *string                `bson:"category" json:"category"`
	Workflow       *string                `bson:"workflow" json:"workflow"`
	CreatedAt      time.Time              `bson:"created_at" json:"created_at"`
	Status         Status                 `bson:"status" json:"status"`
	Attempt        int                    `bson:"attempt" json:"attempt"`
	Session        int                    `bson:"session" json:"session"`
	Result         *Result                `bson:"result" json:"result"`
	FinishedAt     *time.Time             `bson:"finished_at" json:"finished_at"`
	TimeReference  time.Time              `bson:"time_reference" json:"time_reference"`
	Weight         int                    `bson:"weight" json:"weight"`
	ErrorCounter   int                    `bson:"error_counter" json:"error_counter"`
	LastError      *string                `bson:"last_error" json:"last_error"`
}

func NewJob

func NewJob(namespace, _type string) *Job

func (*Job) AddConfig

func (job *Job) AddConfig(key string, value interface{}) *Job

func (*Job) AddPrivate

func (job *Job) AddPrivate(key string, value interface{}) *Job

func (*Job) AddPublic

func (job *Job) AddPublic(key string, value interface{}) *Job

func (*Job) CategoryValue

func (job *Job) CategoryValue() interface{}

func (*Job) DecErrorCounter

func (job *Job) DecErrorCounter()

func (*Job) Failed

func (job *Job) Failed() *Result

func (*Job) Fields

func (job *Job) Fields() []interface{}

func (*Job) Finished

func (job *Job) Finished(value Status)

func (*Job) IncErrorCounter

func (job *Job) IncErrorCounter()

func (*Job) LastErrorMessage

func (job *Job) LastErrorMessage() string

func (*Job) Pending

func (job *Job) Pending() *Result

func (*Job) PrettyJSON

func (job *Job) PrettyJSON() string

func (*Job) SetCategory

func (job *Job) SetCategory(value string) *Job

func (*Job) SetExclusive

func (job *Job) SetExclusive(value bool) *Job

func (*Job) SetID

func (job *Job) SetID(value string) *Job

func (*Job) SetLastError

func (job *Job) SetLastError(value string) *Job

func (*Job) SetMaxAttempts

func (job *Job) SetMaxAttempts(value int) *Job

func (*Job) SetMaxOccurrences

func (job *Job) SetMaxOccurrences(value int) *Job

func (*Job) SetName

func (job *Job) SetName(value string) *Job

func (*Job) SetNamespace

func (job *Job) SetNamespace(value string) *Job

func (*Job) SetOrigin

func (job *Job) SetOrigin(value string) *Job

func (*Job) SetPriority

func (job *Job) SetPriority(value Priority) *Job

func (*Job) SetPriorityCritical

func (job *Job) SetPriorityCritical() *Job

func (*Job) SetPriorityHigh

func (job *Job) SetPriorityHigh() *Job

func (*Job) SetPriorityLow

func (job *Job) SetPriorityLow() *Job

func (*Job) SetPriorityMedium

func (job *Job) SetPriorityMedium() *Job

func (*Job) SetPriorityNone

func (job *Job) SetPriorityNone() *Job

func (*Job) SetRunAfter

func (job *Job) SetRunAfter(value time.Time) *Job

func (*Job) Succeeded

func (job *Job) Succeeded() *Result

func (*Job) WorkflowValue

func (job *Job) WorkflowValue() interface{}

type Priority

type Priority int
const (
	PriorityNone     Priority = 0
	PriorityLow      Priority = 20
	PriorityMedium   Priority = 50
	PriorityHigh     Priority = 80
	PriorityCritical Priority = 100
)

func ToPriority

func ToPriority(value string) (Priority, error)

type Result

type Result struct {
	Status   Status        `bson:"status" json:"status"`
	NextStep string        `bson:"next_step" json:"next_step"`
	Value    string        `bson:"value" json:"value"`
	Duration time.Duration `bson:"duration" json:"duration"`
	ErrMsg   string        `bson:"error" json:"error"`
	Host     string        `bson:"host" json:"host"`
	Worker   string        `bson:"worker" json:"worker"`
	// contains filtered or unexported fields
}

func (*Result) Error

func (r *Result) Error() string

func (*Result) Fields

func (r *Result) Fields() []interface{}

func (*Result) SetDuration

func (r *Result) SetDuration(duration time.Duration) *Result

func (*Result) SetError

func (r *Result) SetError(msg string) *Result

func (*Result) SetErrorf

func (r *Result) SetErrorf(msg string, p ...interface{}) *Result

func (*Result) SetNextStep

func (r *Result) SetNextStep(nextStep string) *Result

func (*Result) SetValue

func (r *Result) SetValue(value string) *Result

type Status

type Status string
const (
	StatusTodo      Status = "todo"
	StatusRunning   Status = "running"
	StatusPending   Status = "pending"
	StatusSucceeded Status = "succeeded"
	StatusFailed    Status = "failed"
)

type Step

type Step struct {
	Namespace      string                 `bson:"namespace" json:"namespace"`
	Type           string                 `bson:"type" json:"type"`
	Config         map[string]interface{} `bson:"config" json:"config"`
	Exclusive      bool                   `bson:"exclusive" json:"exclusive"`
	MaxOccurrences int                    `bson:"max_occurrences" json:"max_occurrences"`
	MaxAttempts    int                    `bson:"max_attempts" json:"max_attempts"`
	Next           map[string]interface{} `bson:"next" json:"next"`
}

type Workflow

type Workflow struct {
	ID          string                 `bson:"_id" json:"id"`
	Name        string                 `bson:"name" json:"name"`
	Description string                 `bson:"description" json:"description"`
	Origin      string                 `bson:"origin" json:"origin"`
	Priority    Priority               `bson:"priority" json:"priority"`
	FirstStep   string                 `bson:"first_step" json:"first_step"`
	AllSteps    map[string]*Step       `bson:"all_steps" json:"all_steps"`
	Data        map[string]interface{} `bson:"data" json:"data"`
	ExternalID  *string                `bson:"external_id" json:"external_id"`
	CreatedAt   time.Time              `bson:"created_at" json:"created_at"`
	Status      Status                 `bson:"status" json:"status"`
	FinishedAt  *time.Time             `bson:"finished_at" json:"finished_at"`
}

func NewWorkflow

func NewWorkflow(firstStep string, allSteps map[string]*Step) *Workflow

func (*Workflow) AddData

func (wf *Workflow) AddData(key string, value interface{}) *Workflow

func (*Workflow) Fields

func (wf *Workflow) Fields() []interface{}

func (*Workflow) Finished

func (wf *Workflow) Finished()

func (*Workflow) SetData

func (wf *Workflow) SetData(data map[string]interface{}) *Workflow

func (*Workflow) SetDescription

func (wf *Workflow) SetDescription(value string) *Workflow

func (*Workflow) SetExternalID

func (wf *Workflow) SetExternalID(value string) *Workflow

func (*Workflow) SetID

func (wf *Workflow) SetID(value string) *Workflow

func (*Workflow) SetName

func (wf *Workflow) SetName(value string) *Workflow

func (*Workflow) SetOrigin

func (wf *Workflow) SetOrigin(value string) *Workflow

func (*Workflow) SetPriority

func (wf *Workflow) SetPriority(value Priority) *Workflow

func (*Workflow) SetPriorityCritical

func (wf *Workflow) SetPriorityCritical() *Workflow

func (*Workflow) SetPriorityHigh

func (wf *Workflow) SetPriorityHigh() *Workflow

func (*Workflow) SetPriorityLow

func (wf *Workflow) SetPriorityLow() *Workflow

func (*Workflow) SetPriorityMedium

func (wf *Workflow) SetPriorityMedium() *Workflow

func (*Workflow) SetPriorityNone

func (wf *Workflow) SetPriorityNone() *Workflow

Jump to

Keyboard shortcuts

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