mqtt

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Copyright (c) Microsoft Corporation. Licensed under the MIT License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ack

type Ack struct {
	ReasonCode     byte
	ReasonString   string
	UserProperties map[string]string
}

Ack contains values from PUBACK/SUBACK/UNSUBACK packets received from the MQTT server.

type ConnectEvent

type ConnectEvent struct {
	ReasonCode byte
}

ConnectEvent contains the relevent metadata provided to the handler when the MQTT client connects to the broker.

type ConnectEventHandler

type ConnectEventHandler = func(*ConnectEvent)

ConnectEventHandler is a user-defined callback function used to respond to connection notifications from the MQTT client.

type DisconnectEvent

type DisconnectEvent struct {
	ReasonCode *byte
	Error      error
}

DisconnectEvent contains the relevent metadata provided to the handler when the MQTT client disconnects from the broker.

type DisconnectEventHandler

type DisconnectEventHandler = func(*DisconnectEvent)

DisconnectEventHandler is a user-defined callback function used to respond to disconnection notifications from the MQTT client.

type Message

type Message struct {
	Topic   string
	Payload []byte
	PublishOptions

	// Ack will manually ack the message. All handled messages must be acked
	// (except for QoS 0 messages, in which case this is a no-op).
	Ack func()
}

Message represents a received message.

type MessageHandler

type MessageHandler = func(context.Context, *Message)

MessageHandler is a user-defined callback function used to handle messages received on the subscribed topic.

type PublishOption

type PublishOption interface {
	// contains filtered or unexported methods
}

PublishOption represents a single publish option.

type PublishOptions

type PublishOptions struct {
	ContentType     string
	CorrelationData []byte
	MessageExpiry   uint32
	PayloadFormat   byte
	QoS             byte
	ResponseTopic   string
	Retain          bool
	UserProperties  map[string]string
}

PublishOptions are the resolved publish options.

func (*PublishOptions) Apply

func (o *PublishOptions) Apply(
	opts []PublishOption,
	rest ...PublishOption,
)

Apply resolves the provided list of options.

type SubscribeOption

type SubscribeOption interface {
	// contains filtered or unexported methods
}

SubscribeOption represents a single subscribe option.

type SubscribeOptions

type SubscribeOptions struct {
	NoLocal        bool
	QoS            byte
	Retain         bool
	RetainHandling byte
	UserProperties map[string]string
}

SubscribeOptions are the resolved subscribe options.

func (*SubscribeOptions) Apply

func (o *SubscribeOptions) Apply(
	opts []SubscribeOption,
	rest ...SubscribeOption,
)

Apply resolves the provided list of options.

type UnsubscribeOption

type UnsubscribeOption interface {
	// contains filtered or unexported methods
}

UnsubscribeOption represents a single unsubscribe option.

type UnsubscribeOptions

type UnsubscribeOptions struct {
	UserProperties map[string]string
}

UnsubscribeOptions are the resolve unsubscribe options.

func (*UnsubscribeOptions) Apply

func (o *UnsubscribeOptions) Apply(
	opts []UnsubscribeOption,
	rest ...UnsubscribeOption,
)

Apply resolves the provided list of options.

type WithContentType

type WithContentType string

WithContentType sets the content type for the publish.

type WithCorrelationData

type WithCorrelationData []byte

WithCorrelationData sets the correlation data for the publish.

type WithMessageExpiry

type WithMessageExpiry uint32

WithMessageExpiry sets the message expiry interval for the publish.

type WithNoLocal

type WithNoLocal bool

WithNoLocal sets the no local flag for the subscription.

type WithPayloadFormat

type WithPayloadFormat byte

WithPayloadFormat sets the payload format indicator for the publish.

type WithQoS

type WithQoS byte

WithQoS sets the QoS level for the publish or subscribe.

type WithResponseTopic

type WithResponseTopic string

WithResponseTopic sets the response topic for the publish.

type WithRetain

type WithRetain bool

WithRetain sets the retain flag for the publish or the retain-as-publish flag for the subscribe.

type WithRetainHandling

type WithRetainHandling byte

WithRetainHandling specifies the handling of retained messages on the subscribe.

type WithUserProperties

type WithUserProperties map[string]string

WithUserProperties sets the user properties for the publish or subscribe.

Jump to

Keyboard shortcuts

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