mqtt_api

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Destroy

func Destroy(api *MqttApi)

func DestroyRouter

func DestroyRouter(router *Router)

Types

type Context

type Context struct {
	// 主题
	Topic string

	// 数据
	Data []byte
	// contains filtered or unexported fields
}

func (*Context) Next

func (c *Context) Next()

func (*Context) Response

func (c *Context) Response(responseIdentifier string, data []byte) error

type Handler

type Handler func(c *Context)

type MqttApi

type MqttApi struct {
	// contains filtered or unexported fields
}

func New

func New(opts ...Option) (*MqttApi, error)

func (*MqttApi) Finish

func (api *MqttApi) Finish()

Finish 终止Api 参数: 无 返回值: 无

func (*MqttApi) Options

func (api *MqttApi) Options() Options

Options 获取Api的选项 参数: 无 返回值: - Api的选项

func (*MqttApi) Router

func (api *MqttApi) Router() *Router

Router 获取Api的路由 参数: - 消息组 返回值: - Api的路由

func (*MqttApi) Start

func (api *MqttApi) Start() error

Start 运行Api 参数: 无 返回值: - 错误

type MqttClient

type MqttClient struct {
	// contains filtered or unexported fields
}

type MqttClientOptions

type MqttClientOptions struct {
	UserName        string
	Password        string
	Address         string
	ClientID        string
	KeepAliveSec    int64
	PingTimeoutSec  int64
	WriteTimeoutSec int64
}

type Option

type Option func(options *Options)

func WithLogSkipPaths

func WithLogSkipPaths(logSkipPaths ...string) Option

WithLogSkipPaths 设置日志跳过的打印路径

func WithMqttOptions

func WithMqttOptions(mqttOptions *MqttClientOptions) Option

WithMqttOptions 设置mqtt配置

func WithTopicPrefix

func WithTopicPrefix(topicPrefix string) Option

WithTopicPrefix 设置topic前缀

type Options

type Options struct {
	// contains filtered or unexported fields
}

func (Options) GetTopicPrefix

func (options Options) GetTopicPrefix() string

type Router

type Router struct {
	Group string
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(group string, globalHandlers []Handler) *Router

func (*Router) AddGlobalHandlers

func (router *Router) AddGlobalHandlers(handlers ...Handler)

func (*Router) AddTopic

func (router *Router) AddTopic(topic string, handlers ...Handler) error

func (*Router) Finish

func (router *Router) Finish()

func (*Router) Start

func (router *Router) Start(mqttOptions *MqttClientOptions) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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