jobs

package
v2.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Example/development jobs repo.

Index

Constants

This section is empty.

Variables

View Source
var Factory job.Factory = factory{}

Factory is a job.Factory that makes "shell-command" type jobs.

Functions

This section is empty.

Types

type Nop

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

Nop is a no-op job that does nothing and always returns success. It's used in place of jobs that we want to include in a job chain but haven't implemented yet.

func NewNop

func NewNop(jid job.Id) *Nop

func (*Nop) Create

func (j *Nop) Create(jobArgs map[string]interface{}) error

func (*Nop) Deserialize

func (j *Nop) Deserialize(bytes []byte) error

func (*Nop) Id

func (j *Nop) Id() job.Id

func (*Nop) Run

func (j *Nop) Run(jobData map[string]interface{}) (job.Return, error)

func (*Nop) Serialize

func (j *Nop) Serialize() ([]byte, error)

func (*Nop) Status

func (j *Nop) Status() string

func (*Nop) Stop

func (j *Nop) Stop() error

type ShellCommand

type ShellCommand struct {
	// Internal data (serialized)
	Cmd  string   `json:"cmd"`            // command to execute
	Args []string `json:"args,omitempty"` // args to cmd

	*sync.RWMutex
	// contains filtered or unexported fields
}

ShellCommand is a job.Job that runs a single shell command with arguments.

func NewShellCommand

func NewShellCommand(jid job.Id) *ShellCommand

NewShellCommand instantiates a new ShellCommand job. This should only be called by the Factory. jobName must be unique within a job chain.

func (*ShellCommand) Create

func (j *ShellCommand) Create(jobArgs map[string]interface{}) error

Create is a job.Job interface method.

func (*ShellCommand) Deserialize

func (j *ShellCommand) Deserialize(bytes []byte) error

Deserialize is a job.Job interface method.

func (*ShellCommand) Id

func (j *ShellCommand) Id() job.Id

Name is a job.Job interface method.

func (*ShellCommand) Run

func (j *ShellCommand) Run(jobData map[string]interface{}) (job.Return, error)

Run is a job.Job interface method.

func (*ShellCommand) Serialize

func (j *ShellCommand) Serialize() ([]byte, error)

Serialize is a job.Job interface method.

func (*ShellCommand) Status

func (j *ShellCommand) Status() string

Status is a job.Job interface method.

func (*ShellCommand) Stop

func (j *ShellCommand) Stop() error

Stop is a job.Job interface method.

type Sleep

type Sleep struct {
	// Internal data (serialized)
	Duration time.Duration `json:"duration"` // how long to sleep

	*sync.Mutex
	// contains filtered or unexported fields
}

Sleep is a job.Job that sleeps for a given time.

func NewSleep

func NewSleep(jid job.Id) *Sleep

NewSleep instantiates a new Sleep job. This should only be called by the Factory. jobName must be unique within a job chain.

func (*Sleep) Create

func (j *Sleep) Create(jobArgs map[string]interface{}) error

Create is a job.Job interface method.

func (*Sleep) Deserialize

func (j *Sleep) Deserialize(bytes []byte) error

Deserialize is a job.Job interface method.

func (*Sleep) Id

func (j *Sleep) Id() job.Id

Id is a job.Job interface method.

func (*Sleep) Run

func (j *Sleep) Run(jobData map[string]interface{}) (job.Return, error)

Run is a job.Job interface method.

func (*Sleep) Serialize

func (j *Sleep) Serialize() ([]byte, error)

Serialize is a job.Job interface method.

func (*Sleep) Status

func (j *Sleep) Status() string

Status is a job.Job interface method.

func (*Sleep) Stop

func (j *Sleep) Stop() error

Stop is a job.Job interface method.

Jump to

Keyboard shortcuts

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