configuration

package
v0.0.0-...-6cd7eb2 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: MIT Imports: 7 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// ServerVersion specifies the current GOST Server version
	ServerVersion string = "v0.5"

	// SensorThingsAPIVersion specifies the supported SensorThings API version
	SensorThingsAPIVersion string = "v1.0"

	// DefaultMaxEntries is used when config maxEntries is empty or $top exceeds this default value
	DefaultMaxEntries int = 200
)

Variables

This section is empty.

Functions

func SetEnvironmentVariables

func SetEnvironmentVariables(conf *Config)

SetEnvironmentVariables changes config settings when certain environment variables are found

Types

type Config

type Config struct {
	Server   ServerConfig   `yaml:"server"`
	Database DatabaseConfig `yaml:"database"`
	MQTT     MQTTConfig     `yaml:"mqtt"`
	Logger   LoggerConfig   `yaml:"logger"`
}

Config contains the settings for the Http server, databases and mqtt

var CurrentConfig Config

CurrentConfig will be set after loading so it can be accessed from outside

func GetConfig

func GetConfig(cfgFile string) (Config, error)

GetConfig retrieves a new configuration from the given config file Fatal when config does not exist or cannot be read

func (*Config) GetExternalServerURI

func (c *Config) GetExternalServerURI() string

GetExternalServerURI gets the external Http server address, trailing slash is removed when present in Config.Server.ExternalUri for example "http://www.mysensorplatform"

func (*Config) GetInternalServerURI

func (c *Config) GetInternalServerURI() string

GetInternalServerURI gets the internal Http server address for example: "localhost:8080"

type DatabaseConfig

type DatabaseConfig struct {
	Host         string `yaml:"host"`
	Port         int    `yaml:"port"`
	User         string `yaml:"user"`
	Password     string `yaml:"password"`
	Database     string `yaml:"database"`
	Schema       string `yaml:"schema"`
	SSL          bool   `yaml:"ssl"`
	MaxIdleConns int    `yaml:"maxIdleConns"`
	MaxOpenConns int    `yaml:"maxOpenConns"`
}

DatabaseConfig contains the database server information, can be overruled by environment variables

type LoggerConfig

type LoggerConfig struct {
	FileName string `yaml:"fileName"`
	Verbose  bool   `yaml:"verbose"`
}

LoggerConfig contains the logging configuration used to initialize the logger

type MQTTConfig

type MQTTConfig struct {
	Enabled         bool   `yaml:"enabled"`
	Verbose         bool   `yaml:"verbose"`
	Host            string `yaml:"host"`
	Prefix          string `yaml:"prefix"`
	ClientID        string `yaml:"clientId"`
	Port            int    `yaml:"port"`
	SubscriptionQos byte   `yaml:"subscriptionQos"`
	Persistent      bool   `yaml:"persistent"`
	Order           bool   `yaml:"order"`
	SSL             bool   `yaml:"ssl"`
	Username        string `yaml:"username"`
	Password        string `yaml:"password"`
	CaCertFile      string `yaml:"caCertFile"`
	ClientCertFile  string `yaml:"clientCertFile"`
	PrivateKeyFile  string `yaml:"privateKeyFile"`
	KeepAliveSec    int    `yaml:"keepAliveSec"`
	PingTimeoutSec  int    `yaml:"pingTimeoutSec"`
}

MQTTConfig contains the MQTT client information

type ServerConfig

type ServerConfig struct {
	Name              string `yaml:"name"`
	Host              string `yaml:"host"`
	Port              int    `yaml:"port"`
	ExternalURI       string `yaml:"externalUri"`
	HTTPS             bool   `yaml:"https"`
	HTTPSCert         string `yaml:"httpsCert"`
	HTTPSKey          string `yaml:"httpsKey"`
	MaxEntityResponse int    `yaml:"maxEntityResponse"`
	IndentedJSON      bool   `yaml:"indentedJson"`
}

ServerConfig contains the general server information

Jump to

Keyboard shortcuts

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