scheduler

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MSchedule  = "wk.scheduler.schedule"
	MScheduled = "wk.scheduler#scheduled"
	MProgress  = "wk.scheduler#progress"
	MSuccess   = "wk.scheduler#success"
	MFailure   = "wk.scheduler#failure"
)

scheduler specifics

Variables

Functions

func Coalesce

func Coalesce(ctx context.Context, handles ...*Future) chan CoalescedResult

func Lock

func Lock(topCtx context.Context) async.Manifest

func NewFailureMessage

func NewFailureMessage(id, handleID xid.ID, err error) message.Message

func NewProgressMessage

func NewProgressMessage(id, handleID xid.ID, current, max int) message.Message

func NewScheduleMessage

func NewScheduleMessage(id xid.ID, args any) message.Message

func NewScheduledMessage

func NewScheduledMessage(name string, id, parentID xid.ID) message.Message

func NewSuccessMessage

func NewSuccessMessage(id, handleID xid.ID) message.Message

func ParentID

func ParentID(ctx context.Context) xid.ID

Types

type CoalescedResult

type CoalescedResult struct {
	Origin xid.ID
	Value  any
	Error  error
}

type Context

type Context struct {
	context.Context
	Cancel    context.CancelFunc
	Scheduler *Scheduler
	Parent    xid.ID
}

func NewContext

func NewContext(parent context.Context, parentID xid.ID) *Context

func (*Context) BindScheduler

func (c *Context) BindScheduler(scheduler *Scheduler)

type FailureMessagePayload

type FailureMessagePayload struct {
	ManifestID xid.ID
	HandleID   xid.ID
	Error      error
}

type Future added in v0.1.3

type Future struct {
	*Context
	ID         xid.ID
	ManifestID xid.ID
	// contains filtered or unexported fields
}

func NewFuture added in v0.1.3

func NewFuture(ctx context.Context, parent xid.ID, manifest async.Manifest) (*Future, chan<- any, chan<- error)

func Schedule

func Schedule(ctx context.Context, manifest async.Manifest, args any) (*Future, error)

func (Future) Error added in v0.1.3

func (h Future) Error() <-chan error

func (Future) Poll added in v0.1.3

func (h Future) Poll(ctx context.Context) (any, error)

func (Future) TryPoll added in v0.1.3

func (h Future) TryPoll(ctx context.Context, duration time.Duration) (any, bool, error)

type Hooks

type Hooks struct {
	OnStart *async.Manifest
	OnStop  *async.Manifest
}

type Pipeline

type Pipeline struct {
	Name      string
	Manifests []async.Manifest
	Hooks     Hooks
}

func MakePipeline

func MakePipeline(name string, hooks Hooks, manifests ...async.Manifest) *Pipeline

func (Pipeline) Manifest

func (p Pipeline) Manifest() async.Manifest

type ProgressMessagePayload

type ProgressMessagePayload struct {
	ManifestID xid.ID
	HandleID   xid.ID
	Current    int
	Max        int
}

type ScheduleMessagePayload

type ScheduleMessagePayload struct {
	ManifestID xid.ID
	Args       any
}

type ScheduledMessagePayload

type ScheduledMessagePayload struct {
	Name     string
	ID       xid.ID
	ParentID xid.ID
}

type Scheduler

type Scheduler struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func New

func New(bus message.Mailbox) *Scheduler

func (*Scheduler) Schedule

func (s *Scheduler) Schedule(parent context.Context, manifest async.Manifest, args any) (*Future, error)

type SuccessMessagePayload

type SuccessMessagePayload struct {
	ManifestID xid.ID
	HandleID   xid.ID
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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