tick

package
v0.0.0-...-5c345c6 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2016 License: MIT Imports: 14 Imported by: 0

README

tick

tick

Usage

func GetIP
func GetIP(config Configer, tracker *acomm.Tracker) (net.IP, error)

GetIP retrieves the ip of the current node, very often needed for ticks.

func RunTick
func RunTick(config Configer, tick ActionFn) (chan struct{}, error)

RunTick runs the supplied function on a configured interval. Putting an entry into the returned chan, as well as sending an os signal, can be used to stop the tick.

type ActionFn
type ActionFn func(Configer, *acomm.Tracker) error

ActionFn is a function that can be run on a tick interval.

type Config
type Config struct {
}

Config is the configuration for a tick.

func NewConfig
func NewConfig(flagSet *pflag.FlagSet, v *viper.Viper) *Config

NewConfig creates a new instance of Config.

func (*Config) ClusterDataURL
func (c *Config) ClusterDataURL() *url.URL

ClusterDataURL returns the url of the layer 2 coordinator, used for cluster information.

func (*Config) ConfigFile
func (c *Config) ConfigFile() string

ConfigFile returns a path to a config file.

func (*Config) LoadConfig
func (c *Config) LoadConfig() error

LoadConfig loads the config.

func (*Config) LogLevel
func (c *Config) LogLevel() string

LogLevel returns the log level.

func (*Config) NodeDataURL
func (c *Config) NodeDataURL() *url.URL

NodeDataURL returns the url of the layer 1 coordinator, used for node information.

func (*Config) RequestTimeout
func (c *Config) RequestTimeout() time.Duration

RequestTimeout returns the default timeout for task requests.

func (*Config) SetupLogging
func (c *Config) SetupLogging() error

SetupLogging sets up logging with the log level and formatting.

func (*Config) TickInterval
func (c *Config) TickInterval() time.Duration

TickInterval returns how often the tick function should be executed.

func (*Config) TickRetryInterval
func (c *Config) TickRetryInterval() time.Duration

TickRetryInterval returns how often the tick function should be executed after an error.

func (*Config) Validate
func (c *Config) Validate() error

Validate ensures the configuration is valid.

func (*Config) ValidateURL
func (c *Config) ValidateURL(name string) error

ValidateURL is used in validation for checking url parameters.

type ConfigData
type ConfigData struct {
	NodeDataURL       string `json:"nodeDataURL"`
	ClusterDataURL    string `json:"clusterDataURL"`
	LogLevel          string `json:"logLevel"`
	RequestTimeout    string `json:"requestTimeout"`
	TickInterval      string `json:"tickInterval"`
	TickRetryInterval string `json:"tickRetryInterval"`
}

ConfigData defines the structure of the config data (e.g. in the config file)

type Configer
type Configer interface {
	ConfigFile() string
	NodeDataURL() *url.URL
	ClusterDataURL() *url.URL
	LogLevel() string
	RequestTimeout() time.Duration
	TickInterval() time.Duration
	TickRetryInterval() time.Duration
}

Configer is an interface that provides information the tick needs to run. It allows more complex configs to be passed through to the tick function.

-- Generated with godocdown

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIP

func GetIP(config Configer, tracker *acomm.Tracker) (net.IP, error)

GetIP retrieves the ip of the current node, very often needed for ticks.

func RunTick

func RunTick(config Configer, tick ActionFn) (chan struct{}, error)

RunTick runs the supplied function on a configured interval. Putting an entry into the returned chan, as well as sending an os signal, can be used to stop the tick.

Types

type ActionFn

type ActionFn func(Configer, *acomm.Tracker) error

ActionFn is a function that can be run on a tick interval.

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is the configuration for a tick.

func NewConfig

func NewConfig(flagSet *pflag.FlagSet, v *viper.Viper) *Config

NewConfig creates a new instance of Config.

func (*Config) ClusterDataURL

func (c *Config) ClusterDataURL() *url.URL

ClusterDataURL returns the url of the layer 2 coordinator, used for cluster information.

func (*Config) ConfigFile

func (c *Config) ConfigFile() string

ConfigFile returns a path to a config file.

func (*Config) LoadConfig

func (c *Config) LoadConfig() error

LoadConfig loads the config.

func (*Config) LogLevel

func (c *Config) LogLevel() string

LogLevel returns the log level.

func (*Config) NodeDataURL

func (c *Config) NodeDataURL() *url.URL

NodeDataURL returns the url of the layer 1 coordinator, used for node information.

func (*Config) RequestTimeout

func (c *Config) RequestTimeout() time.Duration

RequestTimeout returns the default timeout for task requests.

func (*Config) SetupLogging

func (c *Config) SetupLogging() error

SetupLogging sets up logging with the log level and formatting.

func (*Config) TickInterval

func (c *Config) TickInterval() time.Duration

TickInterval returns how often the tick function should be executed.

func (*Config) TickRetryInterval

func (c *Config) TickRetryInterval() time.Duration

TickRetryInterval returns how often the tick function should be executed after an error.

func (*Config) Validate

func (c *Config) Validate() error

Validate ensures the configuration is valid.

func (*Config) ValidateURL

func (c *Config) ValidateURL(name string) error

ValidateURL is used in validation for checking url parameters.

type ConfigData

type ConfigData struct {
	NodeDataURL       string `json:"nodeDataURL"`
	ClusterDataURL    string `json:"clusterDataURL"`
	LogLevel          string `json:"logLevel"`
	RequestTimeout    string `json:"requestTimeout"`
	TickInterval      string `json:"tickInterval"`
	TickRetryInterval string `json:"tickRetryInterval"`
}

ConfigData defines the structure of the config data (e.g. in the config file)

type Configer

type Configer interface {
	ConfigFile() string
	NodeDataURL() *url.URL
	ClusterDataURL() *url.URL
	LogLevel() string
	RequestTimeout() time.Duration
	TickInterval() time.Duration
	TickRetryInterval() time.Duration
}

Configer is an interface that provides information the tick needs to run. It allows more complex configs to be passed through to the tick function.

Jump to

Keyboard shortcuts

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