mqtt

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 19 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAgentOptions

func NewAgentOptions(mqttOptions *MQTTOptions, clusterName, agentID string) *options.CloudEventsAgentOptions

func NewSourceOptions

func NewSourceOptions(mqttOptions *MQTTOptions, clientID, sourceID string) *options.CloudEventsSourceOptions

Types

type MQTTConfig

type MQTTConfig struct {
	// BrokerHost is the host of the MQTT broker (hostname:port).
	BrokerHost string `json:"brokerHost" yaml:"brokerHost"`

	// Username is the username for basic authentication to connect the MQTT broker.
	Username string `json:"username,omitempty" yaml:"username,omitempty"`
	// Password is the password for basic authentication to connect the MQTT broker.
	Password string `json:"password,omitempty" yaml:"password,omitempty"`

	// CAFile is the file path to a cert file for the MQTT broker certificate authority.
	CAFile string `json:"caFile,omitempty" yaml:"caFile,omitempty"`
	// ClientCertFile is the file path to a client cert file for TLS.
	ClientCertFile string `json:"clientCertFile,omitempty" yaml:"clientCertFile,omitempty"`
	// ClientKeyFile is the file path to a client key file for TLS.
	ClientKeyFile string `json:"clientKeyFile,omitempty" yaml:"clientKeyFile,omitempty"`

	// KeepAlive is the keep alive time in seconds for MQTT clients, by default is 60s
	KeepAlive *uint16 `json:"keepAlive,omitempty" yaml:"keepAlive,omitempty"`

	// PubQoS is the QoS for publish, by default is 1
	PubQoS *int `json:"pubQoS,omitempty" yaml:"pubQoS,omitempty"`
	// SubQoS is the Qos for subscribe, by default is 1
	SubQoS *int `json:"subQoS,omitempty" yaml:"subQoS,omitempty"`

	// Topics are MQTT topics for resource spec, status and resync.
	Topics *types.Topics `json:"topics,omitempty" yaml:"topics,omitempty"`
}

MQTTConfig holds the information needed to build connect to MQTT broker as a given user.

type MQTTOptions

type MQTTOptions struct {
	Topics         types.Topics
	BrokerHost     string
	Username       string
	Password       string
	CAFile         string
	ClientCertFile string
	ClientKeyFile  string
	KeepAlive      uint16
	Timeout        time.Duration
	PubQoS         int
	SubQoS         int
}

MQTTOptions holds the options that are used to build MQTT client.

func BuildMQTTOptionsFromFlags

func BuildMQTTOptionsFromFlags(configPath string) (*MQTTOptions, error)

BuildMQTTOptionsFromFlags builds configs from a config filepath.

func (*MQTTOptions) GetCloudEventsClient

func (o *MQTTOptions) GetCloudEventsClient(
	ctx context.Context,
	clientID string,
	errorHandler func(error),
	clientOpts ...cloudeventsmqtt.Option,
) (cloudevents.Client, error)

func (*MQTTOptions) GetMQTTConnectOption

func (o *MQTTOptions) GetMQTTConnectOption(clientID string) *paho.Connect

func (*MQTTOptions) GetNetConn

func (o *MQTTOptions) GetNetConn() (net.Conn, error)

Jump to

Keyboard shortcuts

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