Documentation
¶
Index ¶
Constants ¶
const ( Overlap = "overlap" OnlyOnce = "onlyonce" )
String constants for accepted delivery methods
Variables ¶
var DefaultListeners = []*ListenerConfig{ { Address: "0.0.0.0:1883", TLSOptions: nil, }, { Address: "0.0.0.0:8883", }, }
DefaultListeners are the default listeners for the server
var ( // DefaultMQTTConfig is the default config for MQTT 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, } )
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"` ConfigDir string `yaml:"config_dir"` Persistence Persistence `yaml:"persistence"` TopicAliasManager TopicAliasManager `yaml:"topic_alias_manager"` DumpPacket bool `yaml:"dump_packet"` Logging bool `yaml:"logging"` }
Config is the configration for the mqtt server.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig return the default configuration. If config file is not provided, gmqttd will start with DefaultConfig.
type Configuration ¶
type Configuration interface { // Validate validates the configuration. // If returns error, the broker will not start. Validate() error }
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"` }
ListenerConfig is the (TCP) listener config
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"` }
MQTT is the configuration structure for the MQTT options
type Persistence ¶
type Persistence struct { // Type is the persistence type. // If empty, use "memory" as default. Type PersistenceType `yaml:"type"` }
Persistence is the config of backend persistence.
func (*Persistence) Validate ¶
func (p *Persistence) Validate() error
Validate validates the configuration
type PersistenceType ¶
type PersistenceType = string
PersistenceType is the configuration option for the persistence layer
const (
PersistenceTypeMemory PersistenceType = "memory"
)
Known persistence layer implementations
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"` }
TLSOptions are the TLS options for the server
type TopicAliasManager ¶
type TopicAliasManager struct {
Type TopicAliasType
}
TopicAliasManager is the config of the topic alias manager.
type TopicAliasType ¶
type TopicAliasType = string
TopicAliasType is a type for topic alias factories
const (
TopicAliasMgrTypeFIFO TopicAliasType = "fifo"
)
Topic alias type managerss