Documentation ¶
Overview ¶
Package config is a generated GoMock package.
Index ¶
- Constants
- Variables
- func RegisterDefaultPluginConfig(name string, config Configuration)
- type API
- type Config
- type Configuration
- type Endpoint
- type GRPC
- type ListenerConfig
- type LogConfig
- type MQTT
- type MockConfiguration
- type MockConfigurationMockRecorder
- type Persistence
- type PersistenceType
- type RedisPersistence
- type TLSOptions
- type TopicAliasManager
- type TopicAliasType
- type WebsocketOptions
Constants ¶
const ( Overlap = "overlap" OnlyOnce = "onlyonce" )
Variables ¶
var DefaultListeners = []*ListenerConfig{ { Address: "0.0.0.0:1883", TLSOptions: nil, Websocket: nil, }, { Address: "0.0.0.0:8883", Websocket: &WebsocketOptions{ Path: "/", }, }, }
var ( // DefaultMQTTConfig DefaultMQTTConfig = MQTT{ SessionExpiry: 2 * time.Hour, SessionExpiryCheckInterval: 20 * time.Second, MessageExpiry: 2 * time.Hour, InflightExpiry: 30 * time.Second, MaxPacketSize: packets.MaximumSize, ReceiveMax: 100, MaxKeepAlive: 300, TopicAliasMax: 10, SubscriptionIDAvailable: true, SharedSubAvailable: true, WildcardAvailable: true, RetainAvailable: true, MaxQueuedMsg: 1000, MaxInflight: 100, MaximumQoS: 2, QueueQos0Msg: true, DeliveryMode: OnlyOnce, AllowZeroLenClientID: true, } )
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, }, } )
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 API ¶
type API struct { // GRPC is the gRPC endpoint configuration. GRPC []*Endpoint `yaml:"grpc"` // HTTP is the HTTP endpoint configuration. HTTP []*Endpoint `yaml:"http"` }
API is the configuration for API server. The API server use gRPC-gateway to provide both gRPC and HTTP endpoints.
var DefaultAPI API
type Config ¶
type Config struct { Listeners []*ListenerConfig `yaml:"listeners"` API API `yaml:"api"` MQTT MQTT `yaml:"mqtt,omitempty"` GRPC GRPC `yaml:"gRPC"` Log LogConfig `yaml:"log"` PidFile string `yaml:"pid_file"` ConfigDir string `yaml:"config_dir"` 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 (*Config) UnmarshalYAML ¶
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 Endpoint ¶
type Endpoint struct { // Address is the bind address of the endpoint. // Format: [tcp|unix://][<host>]:<port> // e.g : // * unix:///var/run/gmqttd.sock // * tcp://127.0.0.1:8080 // * :8081 (equal to tcp://:8081) Address string `yaml:"address"` // Map maps the HTTP endpoint to gRPC endpoint. // Must be set if the endpoint is representing a HTTP endpoint. Map string `yaml:"map"` // TLS is the tls configuration. TLS *TLSOptions `yaml:"tls"` }
Endpoint represents a gRPC or HTTP server endpoint.
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.
type MQTT ¶
type MQTT struct { // SessionExpiry is the maximum session expiry interval in seconds. SessionExpiry time.Duration `yaml:"session_expiry"` // SessionExpiryCheckInterval is the interval time for session expiry checker to check whether there // are expired sessions. SessionExpiryCheckInterval time.Duration `yaml:"session_expiry_check_interval"` // MessageExpiry is the maximum lifetime of the message in seconds. // If a message in the queue is not sent in MessageExpiry time, it will be removed, which means it will not be sent to the subscriber. MessageExpiry time.Duration `yaml:"message_expiry"` // InflightExpiry is the lifetime of the "inflight" message in seconds. // If a "inflight" message is not acknowledged by a client in InflightExpiry time, it will be removed when the message queue is full. InflightExpiry time.Duration `yaml:"inflight_expiry"` // MaxPacketSize is the maximum packet size that the server is willing to accept from the client MaxPacketSize uint32 `yaml:"max_packet_size"` // ReceiveMax limits the number of QoS 1 and QoS 2 publications that the server is willing to process concurrently for the client. ReceiveMax uint16 `yaml:"server_receive_maximum"` // MaxKeepAlive is the maximum keep alive time in seconds allows by the server. // If the client requests a keepalive time bigger than MaxKeepalive, // the server will use MaxKeepAlive as the keepalive time. // In this case, if the client version is v5, the server will set MaxKeepalive into CONNACK to inform the client. // But if the client version is 3.x, the server has no way to inform the client that the keepalive time has been changed. MaxKeepAlive uint16 `yaml:"max_keepalive"` // TopicAliasMax indicates the highest value that the server will accept as a Topic Alias sent by the client. // No-op if the client version is MQTTv3.x TopicAliasMax uint16 `yaml:"topic_alias_maximum"` // SubscriptionIDAvailable indicates whether the server supports Subscription Identifiers. // No-op if the client version is MQTTv3.x . SubscriptionIDAvailable bool `yaml:"subscription_identifier_available"` SharedSubAvailable bool `yaml:"shared_subscription_available"` // WildcardSubAvailable indicates whether the server supports Wildcard Subscriptions. WildcardAvailable bool `yaml:"wildcard_subscription_available"` // RetainAvailable indicates whether the server supports retained messages. RetainAvailable bool `yaml:"retain_available"` // MaxQueuedMsg is the maximum queue length of the outgoing messages. // If the queue is full, some message will be dropped. // The message dropping strategy is described in the document of the persistence/queue.Store interface. MaxQueuedMsg int `yaml:"max_queued_messages"` // MaxInflight limits inflight message length of the outgoing messages. // Inflight message is also stored in the message queue, so it must be less than or equal to MaxQueuedMsg. // Inflight message is the QoS 1 or QoS 2 message that has been sent out to a client but not been acknowledged yet. MaxInflight uint16 `yaml:"max_inflight"` // MaximumQoS is the highest QOS level permitted for a Publish. MaximumQoS uint8 `yaml:"maximum_qos"` // QueueQos0Msg indicates whether to store QoS 0 message for a offline session. QueueQos0Msg bool `yaml:"queue_qos0_messages"` // DeliveryMode is the delivery mode. The possible value can be "overlap" or "onlyonce". // It is possible for a client’s subscriptions to overlap so that a published message might match multiple filters. // When set to "overlap" , the server will deliver one message for each matching subscription and respecting the subscription’s QoS in each case. // When set to "onlyonce",the server will deliver the message to the client respecting the maximum QoS of all the matching subscriptions. DeliveryMode string `yaml:"delivery_mode"` // AllowZeroLenClientID indicates whether to allow a client to connect with empty client id. AllowZeroLenClientID bool `yaml:"allow_zero_length_clientid"` }
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 ¶
func (m *MockConfiguration) EXPECT() *MockConfigurationMockRecorder
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 { // CACert is the trust CA certificate file. CACert string `yaml:"cacert"` // Cert is the path to certificate file. Cert string `yaml:"cert"` // Key is the path to key file. Key string `yaml:"key"` // Verify indicates whether to verify client cert. Verify bool `yaml:"verify"` }
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"`
}