jw

package module
v0.0.0-...-5ece1e8 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: MIT Imports: 2 Imported by: 6

README

jw

A FAIRE.

Licence

MIT.


Copyright (c) 2021 mls-361.

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                 `json:"id"`
	Name          string                 `json:"name"`
	Namespace     string                 `json:"namespace"`
	Type          string                 `json:"type"`
	Origin        string                 `json:"origin"`
	Priority      Priority               `json:"priority"`
	Data          map[string]interface{} `json:"data"`
	Private       map[string]interface{} `json:"private"`
	RunAfter      time.Time              `json:"run_after"`
	Retries       int                    `json:"retries"`
	Category      *string                `json:"category"`
	Workflow      *string                `json:"workflow"`
	CreatedAt     time.Time              `json:"created_at"`
	Status        Status                 `json:"status"`
	Attempt       int                    `json:"attempt"`
	Session       int                    `json:"session"`
	Result        *Result                `json:"result"`
	FinishedAt    *time.Time             `json:"finished_at"`
	Weight        int                    `json:"weight"`
	TimeReference time.Time              `json:"time_reference"`
}

Job AFAIRE.

func NewJob

func NewJob(namespace, _type string) *Job

NewJob AFAIRE.

func (*Job) Failed

func (job *Job) Failed() *Result

Failed AFAIRE.

func (*Job) Fields

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

Fields AFAIRE.

func (*Job) Finished

func (job *Job) Finished(status Status)

Finished AFAIRE.

func (*Job) Pending

func (job *Job) Pending() *Result

Pending AFAIRE.

func (*Job) SetCategory

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

SetCategory AFAIRE.

func (*Job) SetData

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

SetData AFAIRE.

func (*Job) SetID

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

SetID AFAIRE.

func (*Job) SetName

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

SetName AFAIRE.

func (*Job) SetOrigin

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

SetOrigin AFAIRE.

func (*Job) SetPriority

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

SetPriority AFAIRE.

func (*Job) SetPriorityCritical

func (job *Job) SetPriorityCritical() *Job

SetPriorityCritical AFAIRE.

func (*Job) SetPriorityHigh

func (job *Job) SetPriorityHigh() *Job

SetPriorityHigh AFAIRE.

func (*Job) SetPriorityLow

func (job *Job) SetPriorityLow() *Job

SetPriorityLow AFAIRE.

func (*Job) SetPriorityMedium

func (job *Job) SetPriorityMedium() *Job

SetPriorityMedium AFAIRE.

func (*Job) SetPriorityNone

func (job *Job) SetPriorityNone() *Job

SetPriorityNone AFAIRE.

func (*Job) SetPrivate

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

SetPrivate AFAIRE.

func (*Job) SetRetries

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

SetRetries AFAIRE.

func (*Job) SetRunAfter

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

SetRunAfter AFAIRE.

func (*Job) Succeeded

func (job *Job) Succeeded() *Result

Succeeded AFAIRE.

type Metrics

type Metrics struct {
	Jobs struct {
		Todo      int
		Pending   int
		Running   int
		Succeeded int
		Failed    int
		Total     int
	}
	Workflows struct {
		Running   int
		Succeeded int
		Failed    int
		Total     int
	}
}

Metrics AFAIRE.

type Model

type Model interface {
	CreateJob(job *Job) (*Job, error)
	NextJob(namespace string) (*Job, error)
	UpdateJob(job *Job) (*Job, error)
	NotifyJob(id string, data interface{}) error
	SetJobPriority(id string, priority Priority) error
	SetJobRunAfter(id string, duration time.Duration) error
	CreateWorkflow(wf *Workflow) (*Workflow, error)
	SetWorkflowPriority(id string, priority Priority) error
}

Model AFAIRE.

type Priority

type Priority int

Priority AFAIRE.

const (
	// PriorityNone AFAIRE.
	PriorityNone Priority = 0

	// PriorityLow AFAIRE.
	PriorityLow Priority = 20

	// PriorityMedium AFAIRE.
	PriorityMedium Priority = 50

	// PriorityHigh AFAIRE.
	PriorityHigh Priority = 80

	// PriorityCritical AFAIRE.
	PriorityCritical Priority = 100
)

type Result

type Result struct {
	Status   Status        `json:"status"`
	NextStep string        `json:"next_step"`
	Value    string        `json:"value"`
	Duration time.Duration `json:"duration"`
	Error    string        `json:"error"`
	Host     string        `json:"host"`
	Worker   string        `json:"worker"`
}

Result AFAIRE.

func (*Result) SetDuration

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

SetDuration AFAIRE.

func (*Result) SetError

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

SetError AFAIRE.

func (*Result) SetNextStep

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

SetNextStep AFAIRE.

func (*Result) SetValue

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

SetValue AFAIRE.

type Runner

type Runner interface {
	Namespace() string
	Model() Model
	RunJob(job *Job, logger logger.Logger)
}

Runner AFAIRE.

type Status

type Status string

Status AFAIRE.

const (
	// StatusTodo AFAIRE.
	StatusTodo Status = "todo"

	// StatusRunning AFAIRE.
	StatusRunning Status = "running"

	// StatusPending AFAIRE.
	StatusPending Status = "pending"

	// StatusSucceeded AFAIRE.
	StatusSucceeded Status = "succeeded"

	// StatusFailed AFAIRE.
	StatusFailed Status = "failed"
)

type Step

type Step struct {
	Namespace string                 `json:"namespace"`
	Type      string                 `json:"type"`
	Config    map[string]interface{} `json:"config"`
	Retries   int                    `json:"retries"`
	Next      map[string]interface{} `json:"next"`
}

Step AFAIRE.

type Storage

type Storage interface {
	ValidateJob(job *Job) error
	InsertJob(job *Job) (bool, error)
	NextJob(namespace string) (*Job, error)
	UpdateJob(job *Job) error
	ValidateWorkflow(wf *Workflow) error
	InsertWorkflow(wf *Workflow, job *Job) error
	Workflow(id string, mustExist bool) (*Workflow, error)
	UpdateWorkflow(wf *Workflow, job, nextJob *Job) error
	Metrics() (*Metrics, error)
}

Storage AFAIRE.

type Workflow

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

Workflow AFAIRE.

func NewWorkflow

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

NewWorkflow AFAIRE.

func (*Workflow) Fields

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

Fields AFAIRE.

func (*Workflow) Finished

func (wf *Workflow) Finished()

Finished AFAIRE.

func (*Workflow) SetData

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

SetData AFAIRE.

func (*Workflow) SetDescription

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

SetDescription AFAIRE.

func (*Workflow) SetExternalID

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

SetExternalID AFAIRE.

func (*Workflow) SetID

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

SetID AFAIRE.

func (*Workflow) SetOrigin

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

SetOrigin AFAIRE.

func (*Workflow) SetPriority

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

SetPriority AFAIRE.

func (*Workflow) SetPriorityCritical

func (wf *Workflow) SetPriorityCritical() *Workflow

SetPriorityCritical AFAIRE.

func (*Workflow) SetPriorityHigh

func (wf *Workflow) SetPriorityHigh() *Workflow

SetPriorityHigh AFAIRE.

func (*Workflow) SetPriorityLow

func (wf *Workflow) SetPriorityLow() *Workflow

SetPriorityLow AFAIRE.

func (*Workflow) SetPriorityMedium

func (wf *Workflow) SetPriorityMedium() *Workflow

SetPriorityMedium AFAIRE.

func (*Workflow) SetPriorityNone

func (wf *Workflow) SetPriorityNone() *Workflow

SetPriorityNone AFAIRE.

func (*Workflow) SetType

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

SetType AFAIRE.

Jump to

Keyboard shortcuts

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