daemon

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2018 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRunner

func NewRunner(daemon Daemon, l fxt.Lifecycle) (*Runner, Err)

NewRunner creates a new daemon runner and registers it in the application lifecycle.

Types

type CronDaemon

type CronDaemon struct {
	Job    CronJob
	Ticker *time.Ticker

	// Blocking means the scheduler does not allow jobs to overlap, there can only be one running at a time.
	Blocking bool
}

CronDaemon is a daemon with an internal scheduler for a CronJob.

func (*CronDaemon) Run

func (d *CronDaemon) Run(quit <-chan struct{}) error

Run implements the Daemon interface.

type CronJob

type CronJob interface {
	// Run runs the job.
	Run() error
}

CronJob is ran by the CronDaemon.

type Daemon

type Daemon interface {
	// Run has a loop inside and quits when it gets a signal from the quit channel.
	// It can handle errors internally or return an error if the daemon can't continue running.
	// Returning nil means the daemon somehow finished working (eg. received an external signal).
	Run(quit <-chan struct{}) error
}

Daemon is a long-running process in the background.

type Err added in v0.3.1

type Err <-chan error

Err accepts an error which causes the application to stop.

type Runner

type Runner struct {
	Daemon Daemon
	// contains filtered or unexported fields
}

Runner runs a daemon.

func (*Runner) Close

func (s *Runner) Close() error

Close sends a quit signal to the daemon.

func (*Runner) Run

func (s *Runner) Run() error

Run runs the daemon itself.

func (*Runner) Shutdown

func (s *Runner) Shutdown(ctx context.Context) error

Shutdown gracefully stops the daemon by sending a quit signal to it and waiting for it to be done.

Jump to

Keyboard shortcuts

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