mockmqtt

package
v0.19.3 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package mockmqtt provides simple standalone mock of mqtt.Client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	ConnectFn     func(ctx context.Context, clientID string, opts ...mqtt.ConnectOption) (sessionPresent bool, err error)
	DisconnectFn  func(ctx context.Context) error
	PublishFn     func(ctx context.Context, message *mqtt.Message) error
	SubscribeFn   func(ctx context.Context, subs ...mqtt.Subscription) ([]mqtt.Subscription, error)
	UnsubscribeFn func(ctx context.Context, subs ...string) error
	PingFn        func(ctx context.Context) error
	// contains filtered or unexported fields
}

Client is a simple mock of mqtt.Client. Handler registered by Handle() can be called by Client.Serve().

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, clientID string, opts ...mqtt.ConnectOption) (sessionPresent bool, err error)

Connect implements mqtt.Client.

func (*Client) Disconnect

func (c *Client) Disconnect(ctx context.Context) error

Disconnect implements mqtt.Client.

func (*Client) Handle

func (c *Client) Handle(handler mqtt.Handler)

Handle implements mqtt.Client.

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

Ping implements mqtt.Client.

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, message *mqtt.Message) error

Publish implements mqtt.Client.

func (*Client) Serve

func (c *Client) Serve(message *mqtt.Message)

Serve implements mqtt.Handler.

func (*Client) Subscribe

func (c *Client) Subscribe(ctx context.Context, subs ...mqtt.Subscription) ([]mqtt.Subscription, error)

Subscribe implements mqtt.Client.

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(ctx context.Context, subs ...string) error

Unsubscribe implements mqtt.Client.

Jump to

Keyboard shortcuts

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