gemq

package
v0.0.0-...-52e5b9a Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenTimeout = errors.New("mqtt token timeout")
	Inc             = &Emq{}
)
View Source
var (
	API = &AuthAPI{}
)

Functions

func DailWithOption

func DailWithOption(opt DialOptions) (c mqtt.Client, err error)

func GetLogger

func GetLogger() util.ItfLogger

func SetGlobalMqttTopicOption

func SetGlobalMqttTopicOption(opt *MqttTopicOption)

Types

type AuthAPI

type AuthAPI struct {
	AuthFunc MqttFunc
	AclFunc  MqttFunc
}

func (*AuthAPI) ACL

func (a *AuthAPI) ACL(c iris.Context, d *AuthRequest) (result *AuthResult, err error)

ACL ...

func (*AuthAPI) Auth

func (a *AuthAPI) Auth(c iris.Context, d *AuthRequest) (result *AuthResult, err error)

Auth ...

func (*AuthAPI) Handle

func (a *AuthAPI) Handle(r iris.Party) iris.Party

Handle ...

type AuthRequest

type AuthRequest struct {
	Username   string `json:"username,omitempty"`
	Password   string `json:"password,omitempty"`
	ClientId   string `json:"clientid,omitempty"`
	PeerHost   string `json:"peerhost,omitempty"`
	ProtoName  string `json:"proto_name,omitempty"`
	MountPoint string `json:"mountpoint,omitempty"`
	Action     string `json:"action,omitempty"`
	Topic      string `json:"topic,omitempty"`
	Qos        string `json:"qos,omitempty"`
	Retain     string `json:"retain,omitempty"`
}

func (*AuthRequest) IsSuperuser

func (a *AuthRequest) IsSuperuser() bool

func (*AuthRequest) Reset

func (a *AuthRequest) Reset()

Reset Empty struct to be used in PoolAuthRequest

type AuthResult

type AuthResult struct {
	Result      string `json:"result"`
	IsSuperuser bool   `json:"is_superuser,omitempty"`
}

type DialOptions

type DialOptions struct {
	AppName string
	//tcp://host:port
	Broker   string
	Username string
	Password string
	// on connect handler
	OnConnectHandler mqtt.OnConnectHandler
}

type Emq

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

Emq ...

func (*Emq) Client

func (e *Emq) Client() mqtt.Client

Client ...

func (*Emq) Connect

func (e *Emq) Connect(opt DialOptions)

Connect ...

func (*Emq) Publish

func (e *Emq) Publish(topic string, payload interface{}, args ...interface{}) (err error)

Publish ... args can be: *MqttTopicOption, MqttTopicOption, time.Duration, bool, byte

func (*Emq) Subscribe

func (e *Emq) Subscribe(topic string, callback mqtt.MessageHandler, args ...interface{}) (err error)

Subscribe ... args can be: *MqttTopicOption, MqttTopicOption, time.Duration, bool, byte

type MqttFunc

type MqttFunc func(c iris.Context, d *AuthRequest) (result *AuthResult, err error)

type MqttTopicOption

type MqttTopicOption struct {
	Timeout time.Duration `json:"timeout,omitempty"`
	Retain  bool          `json:"retain,omitempty"`
	Qos     byte          `json:"qos,omitempty"`
}

Jump to

Keyboard shortcuts

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