config

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2021 License: MIT Imports: 12 Imported by: 7

Documentation

Overview

Package config is a generated GoMock package.

Index

Constants

View Source
const (
	Overlap  = "overlap"
	OnlyOnce = "onlyonce"
)

Variables

View Source
var DefaultListeners = []*ListenerConfig{
	{
		Address:    "0.0.0.0:1883",
		TLSOptions: nil,
		Websocket:  nil,
	},
	{
		Address: "0.0.0.0:8883",
		Websocket: &WebsocketOptions{
			Path: "/",
		},
	},
}
View Source
var (
	// DefaultMQTTConfig
	DefaultMQTTConfig = MQTT{
		SessionExpiry:              2 * time.Hour,
		SessionExpiryCheckInterval: 20 * time.Second,
		MessageExpiry:              2 * time.Hour,
		MaxPacketSize:              packets.MaximumSize,
		ReceiveMax:                 100,
		MaxKeepAlive:               60,
		TopicAliasMax:              10,
		SubscriptionIDAvailable:    true,
		SharedSubAvailable:         true,
		WildcardAvailable:          true,
		RetainAvailable:            true,
		MaxQueuedMsg:               1000,
		MaxInflight:                100,
		MaximumQoS:                 2,
		QueueQos0Msg:               true,
		DeliveryMode:               OnlyOnce,
		AllowZeroLenClientID:       true,
	}
)
View Source
var (

	// DefaultPersistenceConfig is the default value of Persistence
	DefaultPersistenceConfig = Persistence{
		Type: PersistenceTypeMemory,
		Redis: RedisPersistence{
			Addr:        "127.0.0.1:6379",
			Password:    "",
			Database:    0,
			MaxIdle:     &defaultMaxIdle,
			MaxActive:   &defaultMaxActive,
			IdleTimeout: 240 * time.Second,
		},
	}
)
View Source
var (
	// DefaultTopicAliasManager is the default value of TopicAliasManager
	DefaultTopicAliasManager = TopicAliasManager{
		Type: TopicAliasMgrTypeFIFO,
	}
)

Functions

func RegisterDefaultPluginConfig

func RegisterDefaultPluginConfig(name string, config Configuration)

RegisterDefaultPluginConfig registers the default configuration for the given plugin.

Types

type Config

type Config struct {
	Listeners []*ListenerConfig `yaml:"listeners"`
	MQTT      MQTT              `yaml:"mqtt,omitempty"`
	Log       LogConfig         `yaml:"log"`
	PidFile   string            `yaml:"pid_file"`
	Plugins   pluginConfig      `yaml:"plugins"`
	// PluginOrder is a slice that contains the name of the plugin which will be loaded.
	// Giving a correct order to the slice is significant,
	// because it represents the loading order which affect the behavior of the broker.
	PluginOrder       []string          `yaml:"plugin_order"`
	Persistence       Persistence       `yaml:"persistence"`
	TopicAliasManager TopicAliasManager `yaml:"topic_alias_manager"`
}

Config is the configration for gmqttd.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig return the default configuration. If config file is not provided, gmqttd will start with DefaultConfig.

func ParseConfig

func ParseConfig(filePath string) (c Config, err error)

func (Config) GetLogger

func (c Config) GetLogger(config LogConfig) (l *zap.Logger, err error)

func (*Config) UnmarshalYAML

func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error

func (Config) Validate

func (c Config) Validate() (err error)

type Configuration

type Configuration interface {
	// Validate validates the configuration.
	// If returns error, the broker will not start.
	Validate() error
	// Unmarshaler defined how to unmarshal YAML into the config structure.
	yaml.Unmarshaler
}

Configuration is the interface that enable the implementation to parse config from the global config file. Plugin admin and prometheus are two examples.

type ListenerConfig

type ListenerConfig struct {
	Address     string `yaml:"address"`
	*TLSOptions `yaml:"tls"`
	Websocket   *WebsocketOptions `yaml:"websocket"`
}

type LogConfig

type LogConfig struct {
	// Level is the log level. Possible values: debug, info, warn, error
	Level string `yaml:"level"`
	// Format is the log format. Possible values: json, text
	Format string `yaml:"format"`
	// DumpPacket indicates whether to dump MQTT packet in debug level.
	DumpPacket bool `yaml:"dump_packet"`
}

LogConfig is use to configure the log behaviors.

func (LogConfig) Validate added in v0.2.1

func (l LogConfig) Validate() error

type MQTT

type MQTT struct {
	SessionExpiry              time.Duration `yaml:"session_expiry"`
	SessionExpiryCheckInterval time.Duration `yaml:"session_expiry_check_Interval"`
	MessageExpiry              time.Duration `yaml:"message_expiry"`
	MaxPacketSize              uint32        `yaml:"max_packet_size"`
	ReceiveMax                 uint16        `yaml:"server_receive_maximum"`
	MaxKeepAlive               uint16        `yaml:"max_keepalive"`
	TopicAliasMax              uint16        `yaml:"topic_alias_maximum"`
	SubscriptionIDAvailable    bool          `yaml:"subscription_identifier_available"`
	SharedSubAvailable         bool          `yaml:"shared_subscription_available"`
	WildcardAvailable          bool          `yaml:"wildcard_subscription_available"`
	RetainAvailable            bool          `yaml:"retain_available"`
	MaxQueuedMsg               int           `yaml:"max_queued_messages"`
	MaxInflight                uint16        `yaml:"max_inflight"`
	MaximumQoS                 uint8         `yaml:"maximum_qos"`
	QueueQos0Msg               bool          `yaml:"queue_qos0_messages"`
	DeliveryMode               string        `yaml:"delivery_mode"`
	AllowZeroLenClientID       bool          `yaml:"allow_zero_length_clientid"`
}

func (MQTT) Validate

func (c MQTT) Validate() error

type MockConfiguration

type MockConfiguration struct {
	// contains filtered or unexported fields
}

MockConfiguration is a mock of Configuration interface

func NewMockConfiguration

func NewMockConfiguration(ctrl *gomock.Controller) *MockConfiguration

NewMockConfiguration creates a new mock instance

func (*MockConfiguration) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockConfiguration) UnmarshalYAML

func (m *MockConfiguration) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML mocks base method

func (*MockConfiguration) Validate

func (m *MockConfiguration) Validate() error

Validate mocks base method

type MockConfigurationMockRecorder

type MockConfigurationMockRecorder struct {
	// contains filtered or unexported fields
}

MockConfigurationMockRecorder is the mock recorder for MockConfiguration

func (*MockConfigurationMockRecorder) UnmarshalYAML

func (mr *MockConfigurationMockRecorder) UnmarshalYAML(unmarshal interface{}) *gomock.Call

UnmarshalYAML indicates an expected call of UnmarshalYAML

func (*MockConfigurationMockRecorder) Validate

func (mr *MockConfigurationMockRecorder) Validate() *gomock.Call

Validate indicates an expected call of Validate

type Persistence

type Persistence struct {
	// Type is the persistence type.
	// If empty, use "memory" as default.
	Type PersistenceType `yaml:"type"`
	// Redis is the redis configuration and must be set when Type ==  "redis".
	Redis RedisPersistence `yaml:"redis"`
}

Persistence is the config of backend persistence.

func (*Persistence) Validate

func (p *Persistence) Validate() error

type PersistenceType

type PersistenceType = string
const (
	PersistenceTypeMemory PersistenceType = "memory"
	PersistenceTypeRedis  PersistenceType = "redis"
)

type RedisPersistence

type RedisPersistence struct {
	// Addr is the redis server address.
	// If empty, use "127.0.0.1:6379" as default.
	Addr string `yaml:"addr"`
	// Password is the redis password.
	Password string `yaml:"password"`
	// Database is the number of the redis database to be connected.
	Database uint `yaml:"database"`
	// MaxIdle is the maximum number of idle connections in the pool.
	// If nil, use 1000 as default.
	// This value will pass to redis.Pool.MaxIde.
	MaxIdle *uint `yaml:"max_idle"`
	// MaxActive is the maximum number of connections allocated by the pool at a given time.
	// If nil, use 0 as default.
	// If zero, there is no limit on the number of connections in the pool.
	// This value will pass to redis.Pool.MaxActive.
	MaxActive *uint `yaml:"max_active"`
	// Close connections after remaining idle for this duration. If the value
	// is zero, then idle connections are not closed. Applications should set
	// the timeout to a value less than the server's timeout.
	// Ff zero, use 240 * time.Second as default.
	// This value will pass to redis.Pool.IdleTimeout.
	IdleTimeout time.Duration `yaml:"idle_timeout"`
}

RedisPersistence is the configuration of redis persistence.

type TLSOptions

type TLSOptions struct {
	CertFile string `yaml:"cert_file"`
	KeyFile  string `yaml:"key_file"`
}

type TopicAliasManager

type TopicAliasManager struct {
	Type TopicAliasType
}

TopicAliasManager is the config of the topic alias manager.

type TopicAliasType

type TopicAliasType = string
const (
	TopicAliasMgrTypeFIFO TopicAliasType = "fifo"
)

type WebsocketOptions

type WebsocketOptions struct {
	Path string `yaml:"path"`
}

Jump to

Keyboard shortcuts

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