Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- type ClientOption
- func WithCleanSession(clean bool) ClientOption
- func WithClientId(clientId string) ClientOption
- func WithConnectBackoffMaxInterval(maxInterval time.Duration) ClientOption
- func WithConnectTimeout(timeout time.Duration) ClientOption
- func WithConnectionFactory(factory Factory) ClientOption
- func WithDisconnectTimeout(timeout time.Duration) ClientOption
- func WithKeepAliveInterval(interval time.Duration) ClientOption
- func WithKeepAliveTimeout(timeout time.Duration) ClientOption
- func WithLogger(logger *slog.Logger) ClientOption
- func WithOnConnectionStatusHandler(handler OnConnectionStatusHandler) ClientOption
- func WithPassword(password string) ClientOption
- func WithUsername(username string) ClientOption
- type ConnectionStatus
- type ConnectionStatusCode
- type Factory
- type Future
- type OnConnectionStatusHandler
- type OnReceiveHandler
- type QosLevel
- type Result
Constants ¶
View Source
const ( SubackSuccessQoS0 = 0 SubackSuccessQoS1 = 1 SubackSuccessQoS2 = 2 SubackFailure = 128 )
Variables ¶
View Source
var ErrAlreadyRunning = errors.New("client is already running")
View Source
var ErrConnectionClosedForReconnect = errors.New("connection closed for reconnect")
View Source
var ErrConnectionStopped = errors.New("connection stopped")
View Source
var ErrEmptyBroker = errors.New("broker must be provided")
View Source
var ErrEmptyHost = errors.New("empty host")
View Source
var ErrFlushWithNilError = errors.New("signaler must be closed with a non-nil error")
View Source
var ErrNoRequestForResponse = errors.New("no request for response")
View Source
var ErrNoSubscription = errors.New("no subscription matches packet topic name")
View Source
var ErrNotConnack = errors.New("not connack packet")
View Source
var ErrRequestReplaced = errors.New("replaced by new request")
View Source
var ErrSubackReturnedFailureCode = errors.New("suback returned failure")
View Source
var ErrSubscriptionAlreadyRegistered = errors.New("subscription already registered")
View Source
var ErrUnsupportedPacketType = errors.New("unsupported packet type")
View Source
var ErrUnsupportedScheme = errors.New("unsupported broker scheme")
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Run(ctx context.Context) error Publish(ctx context.Context, topic string, payload []byte, qos QosLevel) Future[packets.ControlPacket] Subscribe(ctx context.Context, topic string, qos QosLevel, handler OnReceiveHandler) Future[packets.SubackPacket] Unsubscribe(ctx context.Context, topic string) Future[packets.UnsubackPacket] ReconnectWithCredentials(username string, password string) Reconnect() Status() ConnectionStatus }
type ClientOption ¶
type ClientOption func(*client)
func WithCleanSession ¶
func WithCleanSession(clean bool) ClientOption
func WithClientId ¶
func WithClientId(clientId string) ClientOption
func WithConnectBackoffMaxInterval ¶ added in v1.0.4
func WithConnectBackoffMaxInterval(maxInterval time.Duration) ClientOption
func WithConnectTimeout ¶
func WithConnectTimeout(timeout time.Duration) ClientOption
func WithConnectionFactory ¶
func WithConnectionFactory(factory Factory) ClientOption
func WithDisconnectTimeout ¶
func WithDisconnectTimeout(timeout time.Duration) ClientOption
func WithKeepAliveInterval ¶
func WithKeepAliveInterval(interval time.Duration) ClientOption
func WithKeepAliveTimeout ¶
func WithKeepAliveTimeout(timeout time.Duration) ClientOption
func WithLogger ¶
func WithLogger(logger *slog.Logger) ClientOption
func WithOnConnectionStatusHandler ¶
func WithOnConnectionStatusHandler(handler OnConnectionStatusHandler) ClientOption
func WithPassword ¶
func WithPassword(password string) ClientOption
func WithUsername ¶
func WithUsername(username string) ClientOption
type ConnectionStatus ¶
type ConnectionStatus struct { Code ConnectionStatusCode Err error }
type ConnectionStatusCode ¶
type ConnectionStatusCode = int
const ( Stopped ConnectionStatusCode = iota Connecting Connected Disconnected )
type Future ¶
type OnConnectionStatusHandler ¶
type OnConnectionStatusHandler func(client Client, status ConnectionStatus)
type OnReceiveHandler ¶
type OnReceiveHandler func(client Client, packet packets.PublishPacket) error
Click to show internal directories.
Click to hide internal directories.