config

package
v0.0.0-...-938d0d6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateConf

func UpdateConf(source string, cfile string) error

UpdateConf updates etcd from file and reverse

Types

type Config

type Config struct {
	Server struct {
		Name       string `yaml:"name"`
		Address    string `yaml:"address"`
		MaxWorkers int    `yaml:"maxworkers"`
		Keepalive  int    `yaml:"keepalive"`
		Insecure   bool   `yaml:"insecure"`
		Mtu        int    `yaml:"mtu"`
	} `yaml:"server"`

	Crypto struct {
		Type string `yaml:"type"`
		Key  string `yaml:"key"`
	} `yaml:"crypto"`

	Nodes []struct {
		Node `yaml:"node"`
	} `yaml:"nodes"`

	Etcd struct {
		Endpoints []string `yaml:endpoints`
		Timeout   int      `yaml:timeout`
	} `yaml:"etcd"`

	Revision int `yaml:"revision"`
	// contains filtered or unexported fields
}

Config represents configuration

func New

func New() *Config

New constructs new empty configuration

func (*Config) FromEtcd

func (c *Config) FromEtcd(cfile string) *Config

FromEtcd sets the config source to etcd

func (*Config) FromFile

func (c *Config) FromFile(cfile string) *Config

FromFile sets the config source to file

func (*Config) GetIRB

func (c *Config) GetIRB() map[string][]string

GetIRB returns information route base

func (Config) GetNodesPrivateSubnets

func (c Config) GetNodesPrivateSubnets() []string

GetNodesPrivateSubnets returns all nodes private subnets

func (*Config) Load

func (c *Config) Load() error

Load loads configuration from file / etcd

func (Config) UpdateEtcd

func (c Config) UpdateEtcd(cfile string) error

UpdateEtcd updates etcd from file

func (*Config) Watcher

func (c *Config) Watcher(ctx context.Context, extNotify chan struct{})

Watcher reloads the configuration

func (Config) Whoami

func (c Config) Whoami() (Node, error)

Whoami returns current node config

type Node

type Node struct {
	Name             string   `yaml:"name"`
	Address          string   `yaml:"address"`
	PrivateAddresses []string `yaml:"privateAddresses"`
	PrivateSubnets   []string `yaml:"privateSubnets"`
}

Node represents node / host IP configuration

func (Node) GetPrivateAddresses

func (n Node) GetPrivateAddresses() []string

GetPrivateAddresses gets the node's private addresses

func (Node) GetPrivateSubnets

func (n Node) GetPrivateSubnets() []string

GetPrivateSubnets gets the node's private subnets

Jump to

Keyboard shortcuts

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