config

package
v0.0.0-...-6794c67 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2021 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNameServersFromResolveConfig

func GetNameServersFromResolveConfig(filePath string) ([]string, error)

GetNameServersFromResolveConfig parses a file in the format of /etc/resolv.conf The resolve.conf format is described in resolv.conf(5):

https://man7.org/linux/man-pages/man5/resolv.conf.5.html

This function looks up at the lines starting with `nameserver`. There can be a single nameserver each line and maximum 3 (defined my MAXNS in resolv.h) in the file.

func GetSystemResolvers

func GetSystemResolvers() []string

GetSystemResolvers returns resolvers discovered via /etc/resolv.conf. If not valid resolvers are found, an empty array is returned.

func ParseNameServers

func ParseNameServers(fileContent []byte) []string

ParseNameServers parses an array of bytes and returns the nameservers The content should be of format of /etc/resolv.conf i.e. nameserver 12.0.0.3

Types

type Manager

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

Manager - configuration manager for the service

This manager is multiple goroutines safe. Multiple goroutines can use one of these objects, and data updates are performed asynchronously. When an update function is pushed onto a channel, a single goroutine handles the update. When an update occurs the data is written to the config file. Read access is synchronous, where there is some time between seeing updates to the data. This is patterned after Akka's Agents (https://doc.akka.io/docs/akka/2.5.6/java/agents.html)

func NewManager

func NewManager(configFile string, initialConfig interface{}) *Manager

NewManager - create a new config. There should only be one config for the service.

func (*Manager) Close

func (manager *Manager) Close()

Close - to close out the channel for this object. This should only be called when the service is being shutdown

func (*Manager) UpdateConfig

func (manager *Manager) UpdateConfig(updateFunc func(interface{}) (interface{}, error)) error

UpdateConfig - update the config

Jump to

Keyboard shortcuts

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