agent

package
v0.0.0-...-ed9fe1d Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Overview

Package agent provides the utilities to implement long running command line application

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent interface {
	// Start starts the agent
	Start(ctx context.Context) error
	// Stop stops the agent
	Stop(ctx context.Context) error
	// IsRunning returns the agent is running or not
	IsRunning() bool
}

Agent is an interface to implement an agent feature

type Periodic

type Periodic struct {
	Interval time.Duration
	// contains filtered or unexported fields
}

Periodic is an Agent implementation to run a job by periodic intervals.

func NewPeriodic

func NewPeriodic(job PeriodicJob, interval time.Duration) *Periodic

func (*Periodic) IsRunning

func (p *Periodic) IsRunning() bool

IsRunning implements Agent#IsRunning()

func (*Periodic) Start

func (p *Periodic) Start(ctx context.Context) error

Start implements Agent#Start()

func (*Periodic) Stop

func (p *Periodic) Stop(ctx context.Context) error

Stop implements Agent#Stop()

type PeriodicJob

type PeriodicJob interface {
	RunOnce(ctx context.Context) error
	ShouldRun(ctx context.Context) bool
}

PeriodicJob is a job interface for a periodic agent to run a job

Jump to

Keyboard shortcuts

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