watchdog

package module
v0.0.0-...-beb0de2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2021 License: MIT Imports: 4 Imported by: 0

README

watchdog

Go codecov Go Report Card

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sniffing

func Sniffing(ctx context.Context, dog Dog, sleeper Sleeper, resultChannel chan bool)

Sniffing forever.

func WaitSniffResult

func WaitSniffResult(ctx context.Context, dog Dog, sleeper Sleeper, result bool) chan interface{}

WaitSniffResult keeps sniffing until expected result received.

func WaitSniffed

func WaitSniffed(ctx context.Context, dog Dog, sleeper Sleeper) chan interface{}

WaitSniffed keeps sniffing until sniffed.

func WaitUnSniffed

func WaitUnSniffed(ctx context.Context, dog Dog, sleeper Sleeper) chan interface{}

WaitUnSniffed keeps sniffing until unsinffed.

Types

type Dog

type Dog interface {
	Sniff() bool
}

Dog for monitoring specific status changes.

type Keeper

type Keeper struct {
	Cancel context.CancelFunc
	// contains filtered or unexported fields
}

Keeper runs and collects SniffedEvents of multi-dogs.

func NewKeeper

func NewKeeper() *Keeper

NewKeeper returns a new Keeper for keeping amount of dogs.

func (*Keeper) Keep

func (k *Keeper) Keep(name string, dog Dog) error

Keep for letting dogs sniffing.

func (*Keeper) Run

func (k *Keeper) Run(ctx context.Context, sleeper Sleeper) (<-chan SniffedEvent, error)

Run for collecting SniffedEvent from dogs sniffing.

func (*Keeper) Running

func (k *Keeper) Running() bool

Running repressents the Keeper is running.

func (*Keeper) String

func (k *Keeper) String() string

type ProcessAliveDog

type ProcessAliveDog struct {
	Pid int
}

ProcessAliveDog for checking if process is alive or not via its Pid.

func NewProcessAliveDog

func NewProcessAliveDog(pid int) *ProcessAliveDog

NewProcessAliveDog creates a ProcessAliveDog via the Pid of a process it is watching.

func (ProcessAliveDog) Sniff

func (dog ProcessAliveDog) Sniff() bool

Sniff checks if process is alive or not via its Pid.

type Sleeper

type Sleeper interface {
	Sleep()
}

Sleeper for controlling the delay duration.

type SniffedEvent

type SniffedEvent struct {
	Dog     string
	Sniffed bool
}

SniffedEvent represents the Dog.Sniff() result of specific Dog.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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