worker

package
v0.0.0-...-1f40b3c Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(key string, task CronJob)

Run a particular job

Example
package main

import (
	"github.com/fossapps/starter/mock"
	"github.com/fossapps/starter/worker"
)

func main() {
	mock := mock.ExampleMockJob{}
	worker.Run("key", mock)
}
Output:

running mock job

Types

type CronJob

type CronJob interface {
	Job() captain.Worker
	LockProvider() captain.LockProvider
	ResultProcessor() captain.ResultProcessor
	RuntimeProcessor() captain.RuntimeProcessor
	ShouldRun(key string) bool
}

CronJob any cron must satisfy this permission to run

type TestWorker

type TestWorker struct{}

TestWorker a sample worker

func (TestWorker) Job

func (job TestWorker) Job() captain.Worker

Job actual task to be performed by worker

func (TestWorker) LockProvider

func (job TestWorker) LockProvider() captain.LockProvider

LockProvider no lock provider implementation for now

func (TestWorker) ResultProcessor

func (job TestWorker) ResultProcessor() captain.ResultProcessor

ResultProcessor act on result

func (TestWorker) RuntimeProcessor

func (job TestWorker) RuntimeProcessor() captain.RuntimeProcessor

RuntimeProcessor monitors worker every tick

func (TestWorker) ShouldRun

func (job TestWorker) ShouldRun(key string) bool

ShouldRun returns weather or not this worker should run given a particular key

Jump to

Keyboard shortcuts

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