config

package
v0.0.0-...-b9f6a0d Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultPort ...
	DefaultPort = 1450
)
View Source
const ProtocolVersion = 1

ProtocolVersion ...

Variables

This section is empty.

Functions

func SanitizeAndSplitLine

func SanitizeAndSplitLine(input string) []string

SanitizeAndSplitLine ...

Types

type AutonomousSystem

type AutonomousSystem struct {
	Number       int `json:"number" mapstructure:"number"`
	LinkCapacity int `json:"link_capacity" mapstructure:"link_capacity"`
	Cost         int `json:"cost" mapstructure:"cost"`
}

AutonomousSystem ...

func ExtractAutonomousSystemFromLine

func ExtractAutonomousSystemFromLine(input string) (*AutonomousSystem, error)

ExtractAutonomousSystemFromLine ...

type Config

type Config struct {
	DevelopmentMode            bool               `json:"development_mode" mapstructure:"development_mode"`
	Protocol                   int                `json:"protocol" mapstructure:"protocol"`
	Port                       int                `json:"port" mapstructure:"port"`
	MinPeers                   int                `json:"min_peers" mapstructure:"min_peers"`
	MaxPeers                   int                `json:"max_peers" mapstructure:"max_peers"`
	Cron                       string             `json:"cron" mapstructure:"cron"`
	CostEstimatorPath          string             `json:"cost_estimator_path" mapstructure:"cost_estimator_path"`
	LogLevel                   string             `json:"log_level" mapstructure:"log_level"`
	Self                       *RouteController   `json:"self" mapstructure:"self"`
	ConnectedRouteControllers  []RouteController  `json:"connected_route_controllers" mapstructure:"connected_route_controllers"`
	ConnectedAutonomousSystems []AutonomousSystem `json:"connected_autonomous_systems" mapstructure:"connected_autonomous_systems"`
}

Config ...

func DecodeJSONConfig

func DecodeJSONConfig(r io.Reader) (*Config, error)

DecodeJSONConfig ...

func (*Config) SaveAsJSON

func (c *Config) SaveAsJSON(path string) error

SaveAsJSON ...

type ConfigExtension

type ConfigExtension int

ConfigExtension ...

const (
	// JSON ...
	JSON ConfigExtension = iota
	// TOML ...
	TOML
	// XML ...
	XML
	// CONF ...
	CONF
)

func (ConfigExtension) String

func (e ConfigExtension) String() string

String ...

type ConfigFactory

type ConfigFactory struct {
	sync.Once
	DevelopmentMode bool   `json:"development_mode" mapstructure:"development_mode"`
	Protocol        int    `json:"protocol" mapstructure:"protocol"`
	Port            int    `json:"port" mapstructure:"port"`
	Cron            string `json:"cron" mapstructure:"cron"`
	LogLevel        string `json:"log_level" mapstructure:"log_level"`
	MinPeers        int    `json:"min_peers" mapstructure:"min_peers"`
	MaxPeers        int    `json:"max_peers" mapstructure:"max_peers"`
}

ConfigFactory is used to add extra metadata the server needs to a config struct parsed from raw config file

func DefaultConfigFactory

func DefaultConfigFactory() *ConfigFactory

DefaultConfigFactory ...

func MergeFactory

func MergeFactory(a, b *ConfigFactory) *ConfigFactory

MergeFactory ...

func (*ConfigFactory) DecodeRawConfig

func (c *ConfigFactory) DecodeRawConfig(r io.Reader) (*Config, error)

DecodeRawConfig ...

func (*ConfigFactory) Init

func (c *ConfigFactory) Init()

Init ...

func (*ConfigFactory) New

func (c *ConfigFactory) New(self *RouteController, connectedRouteControllers []RouteController, connectedAutonomousSystems []AutonomousSystem) *Config

New returns a new config struct

func (*ConfigFactory) ReadConfigPaths

func (c *ConfigFactory) ReadConfigPaths(paths []string, extension ConfigExtension) (map[string]Config, error)

ReadConfigPaths ...

type RouteController

type RouteController struct {
	ID                     int    `json:"id" mapstructure:"id"`
	AutonomousSystemNumber int    `json:"autonomous_system_number" mapstructure:"autonomous_system_number"`
	IP                     string `json:"ip" mapstructure:"ip"`
}

RouteController ...

func ExtractRouteControllerFromLine

func ExtractRouteControllerFromLine(input string) (*RouteController, error)

ExtractRouteControllerFromLine ...

Jump to

Keyboard shortcuts

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