config

package
v0.0.0-...-f81ab52 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2017 License: Apache-2.0 Imports: 9 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ReU0   *regexp.Regexp
	ReWild *regexp.Regexp
)

Functions

func IsNil

func IsNil(str NilOrString) bool

func String

func String(str NilOrString) string

func ValidMqttPublishTopic

func ValidMqttPublishTopic(v interface{}, param string) error

ValidMqttPublishTopic validates the Topic is validate or not This is used with validator packages.

Types

type AnyError

type AnyError interface{}

type Config

type Config struct {
	GatewayName string
	BrokerNames []string

	Sections []ConfigSection
}

func LoadConfig

func LoadConfig(confPath string) (Config, error)

LoadConfig loads toml format file from confPath arg and returns []ConfigSection. ConfigSection has a Type, Name and arg. example: [[broker."sango"]] [[broker."sango/1"]] [[broker."sango/2"]]

ret = [

ConfigSection{Type: "broker", Name: "sango"},
ConfigSection{Type: "broker", Name: "sango", Arg: "1"},
ConfigSection{Type: "broker", Name: "sango", Arg: "2"},

]

func LoadConfigByte

func LoadConfigByte(conf []byte) (Config, error)

LoadConfigByte returns []ConfigSection from []byte. This is invoked from LoadConfig.

type ConfigSection

type ConfigSection struct {
	Title string
	Type  string
	Name  string
	Arg   string

	Values ValueMap
}

func SearchDeviceType

func SearchDeviceType(sections *[]ConfigSection, arg string) *ConfigSection

SearchDeviceType find the device section matched type name string

func SearchSection

func SearchSection(sections *[]ConfigSection, t, arg string) *ConfigSection

SearchSection finds the section matched condition args.

type ConfigToml

type ConfigToml struct {
	Gateway SectionMap `toml:"gateway"`
	Brokers SectionMap `toml:"broker"`
	Devices SectionMap `toml:"device"`
	Status  SectionMap `toml:"status"`
}

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type NilOrString

type NilOrString interface{}

NilOrString defines the value is nil or empty

type SectionMap

type SectionMap map[string]interface{}

type ValueMap

type ValueMap map[string]string

Jump to

Keyboard shortcuts

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