polling

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FinishedResult = &commandResult{}

FinishedResult is a sentinel can be returned by a PollerFunc to signal polling should exit

Functions

This section is empty.

Types

type Poller

type Poller struct {
	Channel      chan interface{}
	Poll         PollerFunc
	WaitInterval time.Duration
	// contains filtered or unexported fields
}

Poller represents everything needed for polling a function

func NewPoller

func NewPoller(poll PollerFunc, interval time.Duration) *Poller

NewPoller creates a new poller for a function with a polling interval NOTE: the polling function cannot return `nil`

func (*Poller) IsFinished

func (p *Poller) IsFinished() bool

IsFinished returns whether or not the polling worker has completed

func (*Poller) IsRunning

func (p *Poller) IsRunning() bool

IsRunning returns whether or not the poller is able to be started

func (*Poller) IsStopped

func (p *Poller) IsStopped() bool

IsStopped returns whether or not the polling worker has been stopped or is finished perhaps should be refactored to IsClosed, or IsRunnable

func (*Poller) Start

func (p *Poller) Start()

Start starts the polling process -- cannot be restarted after stopping

func (*Poller) Stop

func (p *Poller) Stop()

Stop exits the polling loop on the next attempt, waits for it to finish, and closes the channel

func (*Poller) StopAndBlock

func (p *Poller) StopAndBlock()

StopAndBlock stops the poller and blocks until it is closed

type PollerFunc

type PollerFunc func() interface{}

PollerFunc is a function to be polled

type PollerManager

type PollerManager interface {
	AddPoller(pollerType, name string, poller *Poller)
	GetPoller(pollerType, name string) *Poller
	HasPoller(pollerType, name string) bool
	RemovePoller(pollerType, name string) bool
	PollerIsRunning(pollerType, name string) bool
}

func NewManager

func NewManager() PollerManager

Jump to

Keyboard shortcuts

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