watches

package
v0.0.0-...-8018142 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2021 License: MPL-2.0 Imports: 7 Imported by: 6

README

watches

GoDoc

Documentation

Overview

Package watches manages the configuration and running of Consul service monitoring

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name string `mapstructure:"name"`

	Poll int    `mapstructure:"interval"` // time in seconds
	Tag  string `mapstructure:"tag"`
	DC   string `mapstructure:"dc"` // Consul datacenter
	// contains filtered or unexported fields
}

Config configures the watch

func NewConfigs

func NewConfigs(raw []interface{}, disc discovery.Backend) ([]*Config, error)

NewConfigs parses json config into a validated slice of Configs

func (*Config) String

func (cfg *Config) String() string

String implements the stdlib fmt.Stringer interface for pretty-printing

func (*Config) Validate

func (cfg *Config) Validate(disc discovery.Backend) error

Validate ensures Config meets all requirements

type Watch

type Watch struct {
	Name string

	events.Publisher
	// contains filtered or unexported fields
}

Watch represents an event to signal when something changes

func FromConfigs

func FromConfigs(cfgs []*Config) []*Watch

FromConfigs creates Watches from a slice of validated Configs

func NewWatch

func NewWatch(cfg *Config) *Watch

NewWatch creates a Watch from a validated Config

func (*Watch) CheckForUpstreamChanges

func (watch *Watch) CheckForUpstreamChanges() (bool, bool)

CheckForUpstreamChanges checks the service discovery endpoint for any changes in a dependent backend. Returns true when there has been a change.

func (*Watch) Receive

func (watch *Watch) Receive(event events.Event)

Receive receives an event into the internal control channel.

func (*Watch) Run

func (watch *Watch) Run(pctx context.Context, bus *events.EventBus)

Run executes the event loop for the Watch

func (*Watch) String

func (watch *Watch) String() string

String implements the stdlib fmt.Stringer interface for pretty-printing

func (*Watch) Tick

func (watch *Watch) Tick() time.Duration

Tick returns the watcher's ticker time duration.

Jump to

Keyboard shortcuts

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