mvpjobs

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Idempotent = Behavior(0)
	Repeatable = Behavior(1)
	Cron       = Behavior(2)
)

Variables

This section is empty.

Functions

func EncodeParams

func EncodeParams(in Params) []byte

Types

type Behavior

type Behavior int

func ParseBehavior

func ParseBehavior(s string) (Behavior, error)

func (*Behavior) DecodeMsgpack

func (v *Behavior) DecodeMsgpack(dec *msgpack.Decoder) error

func (Behavior) EncodeMsgpack

func (v Behavior) EncodeMsgpack(enc *msgpack.Encoder) error

func (Behavior) IsRepeatable

func (v Behavior) IsRepeatable() bool

func (Behavior) MarshalText

func (v Behavior) MarshalText() ([]byte, error)

func (Behavior) String

func (v Behavior) String() string

func (*Behavior) UnmarshalText

func (v *Behavior) UnmarshalText(b []byte) error

type EnqueueOptions

type EnqueueOptions struct {
	RunTime time.Time `msgpack:"rt,omitempty"`
}

type Job

type Job struct {
	ID        JobID           `msgpack:"-"`
	Kind      string          `msgpack:"k"`
	Name      string          `msgpack:"n"`
	RawParams json.RawMessage `msgpack:"p"`

	Status      Status    `msgpack:"s2,omitempty"`
	NextRunTime time.Time `msgpack:"rt,omitempty"`
	Step        string    `msgpack:"sp,omitempty"`
	RawState    []byte    `msgpack:"st,omitempty"`

	EnqueueTime     time.Time `msgpack:"tq,omitempty"`
	StartTime       time.Time `msgpack:"ts,omitempty"`
	LastAttemptTime time.Time `msgpack:"ta,omitempty"`
	FinishTime      time.Time `msgpack:"tf,omitempty"`
	LastSuccessTime time.Time `msgpack:"tls,omitempty"`
	LastFailureTime time.Time `msgpack:"tlf,omitempty"`

	Attempt        int           `msgpack:"a,omitempty"`
	ConsecFailures int           `msgpack:"failc,omitempty"`
	TotalFailures  int           `msgpack:"failt,omitempty"`
	LastErr        string        `msgpack:"errl,omitempty"`
	LastDuration   time.Duration `msgpack:"durl,omitempty"`
	TotalDuration  time.Duration `msgpack:"durt,omitempty"`
}

func (*Job) IsAnonymous

func (j *Job) IsAnonymous() bool

func (*Job) KindName

func (j *Job) KindName() KindName

type JobID

type JobID = flake.ID

type Kind

type Kind struct {
	Name           string
	Behavior       Behavior
	Persistence    Persistence
	Method         *mvprpc.Method
	Set            string
	RepeatInterval time.Duration
	Backoff        backoff.Backoff
	Enabled        bool
	Handler        any
	// contains filtered or unexported fields
}

func (*Kind) AllowNames

func (k *Kind) AllowNames() bool

func (*Kind) IsCron

func (k *Kind) IsCron() bool

func (*Kind) IsPersistent added in v0.2.2

func (k *Kind) IsPersistent() bool

type KindName

type KindName struct {
	Kind string
	Name string
}

func (KindName) IsAnonymous

func (kn KindName) IsAnonymous() bool

type NoParams

type NoParams struct{}

func (NoParams) JobName

func (_ NoParams) JobName() string

func (NoParams) SetJobName

func (_ NoParams) SetJobName(name string)

type Params

type Params interface {
	JobName() string
	SetJobName(name string)
	JobAccountID() flake.ID
}

type Persistence

type Persistence int
const (
	Persistent Persistence = 1
	Ephemeral  Persistence = 2
)

func ParsePersistence

func ParsePersistence(s string) (Persistence, error)

func (*Persistence) DecodeMsgpack

func (v *Persistence) DecodeMsgpack(dec *msgpack.Decoder) error

func (Persistence) EncodeMsgpack

func (v Persistence) EncodeMsgpack(enc *msgpack.Encoder) error

func (Persistence) MarshalText

func (v Persistence) MarshalText() ([]byte, error)

func (Persistence) String

func (v Persistence) String() string

func (*Persistence) UnmarshalText

func (v *Persistence) UnmarshalText(b []byte) error

type Request

type Request struct {
	Kind   string          `msgpack:"k"`
	Name   string          `msgpack:"n"`
	Params json.RawMessage `msgpack:"p"`
	EnqueueOptions
}

type Schema

type Schema struct {
	Name string
	// contains filtered or unexported fields
}

func (*Schema) Define

func (scm *Schema) Define(kindName string, inOrFunc any, behavior Behavior, opts ...any) *Kind

func (*Schema) EphemeralKindNames added in v0.2.2

func (scm *Schema) EphemeralKindNames() []string

func (*Schema) Include

func (scm *Schema) Include(peer *Schema)

func (*Schema) KindByName

func (schema *Schema) KindByName(kindName string) *Kind

func (*Schema) Kinds

func (scm *Schema) Kinds() []*Kind

func (*Schema) PersistentKindNames added in v0.2.2

func (scm *Schema) PersistentKindNames() []string

type Set

type Set struct {
	// contains filtered or unexported fields
}

type Status

type Status int
const (
	StatusNone Status = iota
	StatusQueued
	StatusBlocked
	StatusRunning
	StatusRunningPending // for re-entrant jobs
	StatusWaiting
	StatusRetrying
	StatusDone
	StatusFailed
	StatusFailedSkipped
)

func ParseStatus

func ParseStatus(s string) (Status, error)

func (Status) IsPending

func (s Status) IsPending() bool

func (Status) IsRunning

func (s Status) IsRunning() bool

func (Status) IsTerminal

func (s Status) IsTerminal() bool

func (Status) MarshalText

func (v Status) MarshalText() ([]byte, error)

func (Status) String

func (v Status) String() string

func (*Status) UnmarshalText

func (v *Status) UnmarshalText(b []byte) error

type WithEnabled added in v0.2.2

type WithEnabled bool

type WithRepeatInterval added in v0.2.2

type WithRepeatInterval time.Duration

Jump to

Keyboard shortcuts

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