job

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorJobPanic

type ErrorJobPanic struct {
	Message string
}

ErrorJobPanic Error returned when a Job panics

func (ErrorJobPanic) Error

func (e ErrorJobPanic) Error() string

func (ErrorJobPanic) Unwrap

func (e ErrorJobPanic) Unwrap() error

type ErrorJobStarted

type ErrorJobStarted struct {
	Message string
}

ErrorJobStarted Error returned when a has already started.

func (ErrorJobStarted) Error

func (e ErrorJobStarted) Error() string

func (ErrorJobStarted) Unwrap

func (e ErrorJobStarted) Unwrap() error

type Job

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

Job Wraps JobFun and provide:

  1. Creation, Start, and Finish Time
  2. Recover From Panics

func NewJob

func NewJob(jobFunc func()) *Job

NewJob Create new Job, id is assigned a UUID instead.

func NewJobWithID

func NewJobWithID(id string, jobFunc func()) *Job

NewJobWithID Create new Job with the supplied Id.

func (*Job) ActualElapsed

func (j *Job) ActualElapsed() time.Duration

ActualElapsed Return the actual time of procession of Job. Return -1 if job hasn't started yet.

func (*Job) ID

func (j *Job) ID() string

ID Return Job ID

func (*Job) Run

func (j *Job) Run() error

Run Run the internal Job (synchronous)

func (*Job) State

func (j *Job) State() State

State Return Job current state.

func (*Job) TotalElapsed

func (j *Job) TotalElapsed() time.Duration

TotalElapsed Returns the total time between creation of object and finishing processing its job. Return -1 if job hasn't started yet.

type State

type State int64

State Indicate the state of the Job

const (
	// NEW Job has just been created and hasn't started yet
	NEW State = iota
	// RUNNING Job started and is running.
	RUNNING
	// FINISHED Job started and finished processing.
	FINISHED
	// PANICKED Job started and finished but encountered a panic.
	PANICKED
)

func (State) String

func (s State) String() string

Jump to

Keyboard shortcuts

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