config

package
v0.0.0-...-c408d52 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	LogLevel:                          "info",
	LogFormat:                         "pretty",
	MetricsEnabled:                    true,
	MetricsAddress:                    ":8888",
	MetricsPath:                       "/metrics",
	MQTTTCPAddress:                    ":1883",
	MQTTShutdownTimeout:               15,
	MQTTBufferSize:                    1024,
	MQTTMaxSessionExpiryInterval:      7200,
	MQTTMaxMessageExpiryInterval:      86400,
	MQTTSysTopicUpdateInterval:        1,
	MQTTMaxTopicAlias:                 65535,
	MQTTMaxOutboundMessages:           8192,
	MQTTReceiveMaximum:                1024,
	MQTTMaximumQoS:                    2,
	MQTTRetainAvailable:               true,
	MQTTWildcardSubscriptionAvailable: true,
	MQTTSubscriptionIDAvailable:       true,
	MQTTSharedSubscriptionAvailable:   true,
	MQTTMinProtocolVersion:            3,
}

DefaultConfig contains the default configuration.

Functions

func ReadConfigFile

func ReadConfigFile() error

ReadConfigFile reads the configuration file.

The configuration file can be stored at one of the following locations:

  • /etc/maxmq.conf
  • /etc/maxmq/maxmq.conf

Types

type Config

type Config struct {
	// The minimal severity level to log.
	LogLevel string `mapstructure:"log_level"`

	// The log format.
	LogFormat string `mapstructure:"log_format"`

	// The ID of the machine.
	MachineID int `mapstructure:"machine_id"`

	// Indicate whether the server exports metrics or not.
	MetricsEnabled bool `mapstructure:"metrics_enabled"`

	// TCP address (<IP>:<port>) where the Prometheus metrics are exported.
	MetricsAddress string `mapstructure:"metrics_address"`

	// The path where the metrics are exported.
	MetricsPath string `mapstructure:"metrics_path"`

	// Indicate whether the profiling metrics are exported or not.
	MetricsProfiling bool `mapstructure:"metrics_profiling"`

	// TCP address (<IP>:<port>) that the MQTT will bind to.
	MQTTTCPAddress string `mapstructure:"mqtt_tcp_address"`

	// The number of seconds to wait for the MQTT server to shut down gracefully.
	MQTTShutdownTimeout int `mapstructure:"mqtt_shutdown_timeout"`

	// The size, in bytes, of the MQTT receiver and transmitter buffers.
	MQTTBufferSize int `mapstructure:"mqtt_buffer_size"`

	// The maximum size, in bytes, allowed for MQTT Packets.
	MQTTMaxPacketSize int `mapstructure:"mqtt_max_packet_size"`

	// The maximum period, in seconds, a MQTT session is still valid after the network connection with the client has
	// been closed.
	MQTTMaxSessionExpiryInterval int `mapstructure:"mqtt_max_session_expiry_interval"`

	// The maximum period, in seconds, a MQTT message is still valid.
	MQTTMaxMessageExpiryInterval int `mapstructure:"mqtt_max_message_expiry_interval"`

	// The interval, in seconds, to send MQTT messages in the $SYS topic.
	MQTTSysTopicUpdateInterval int `mapstructure:"mqtt_sys_topic_update_interval"`

	// The maximum number of topic aliases that an MQTT V5 client is allowed to create.
	MQTTMaxTopicAlias int `mapstructure:"mqtt_max_topic_alias"`

	// The maximum number of outbound message for a client.
	MQTTMaxOutboundMessages int `mapstructure:"mqtt_max_outbound_messages"`

	// The maximum number of QoS 1 and QoS 2 publications that it is willing to process concurrently.
	MQTTReceiveMaximum int `mapstructure:"mqtt_receive_maximum"`

	// The maximum MQTT QoS for PUBLISH Packets accepted by the server.
	MQTTMaximumQoS byte `mapstructure:"mqtt_max_qos"`

	// Indicate whether the server allows retained MQTT messages or not.
	MQTTRetainAvailable bool `mapstructure:"mqtt_retain_available"`

	// Indicate whether the server allows MQTT wildcard subscription or not.
	MQTTWildcardSubscriptionAvailable bool `mapstructure:"mqtt_wildcard_subscription_available"`

	// Indicate whether the server allows MQTT subscription identifier or not.
	MQTTSubscriptionIDAvailable bool `mapstructure:"mqtt_subscription_identifier_available"`

	// Indicate whether the server allows MQTT shared subscription or not.
	MQTTSharedSubscriptionAvailable bool `mapstructure:"mqtt_shared_subscription_available"`

	// Set the minimal MQTT protocol version.
	MQTTMinProtocolVersion byte `mapstructure:"mqtt_min_protocol_version"`
}

Config holds all the application configuration.

func LoadConfig

func LoadConfig() (c Config, err error)

LoadConfig loads the configuration from the conf file, environment variables, or use the default values.

Note: The ReadConfigFile must be called before in order to load the configuration from the conf file.

Jump to

Keyboard shortcuts

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