mqttproxy

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Connected is MQTT client status of Connected
	Connected = 1
	// Disconnected is MQTT client status of Disconnected
	Disconnected = 2

	// QoS0 for "At most once"
	QoS0 byte = 0
	// QoS1 for "At least once
	QoS1 byte = 1
	// QoS2 for "Exactly once"
	QoS2 byte = 2
)
View Source
const (
	// Category is the category of MQTTProxy.
	Category = supervisor.CategoryBusinessController

	// Kind is the kind of MQTTProxy.
	Kind = "MQTTProxy"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	UserName   string `yaml:"userName" jsonschema:"required"`
	PassBase64 string `yaml:"passBase64" jsonschema:"required"`
}

Auth describes username and password for MQTTProxy

type Broker

type Broker struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Broker is MQTT server, will manage client, topic, session, etc.

type Certificate

type Certificate struct {
	Name string `yaml:"name" jsonschema:"required"`
	Cert string `yaml:"cert" jsonschema:"required"`
	Key  string `yaml:"key" jsonschema:"required"`
}

Certificate describes TLS certifications.

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client represents a MQTT client connection in Broker

type ClientInfo

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

ClientInfo is basic infomation for client

type HTTPJsonData

type HTTPJsonData struct {
	Topic       string `json:"topic"`
	QoS         int    `json:"qos"`
	Payload     string `json:"payload"`
	Base64      bool   `json:"base64"`
	Distributed bool   `json:"distributed"`
}

HTTPJsonData is json data received from http endpoint used to send back to clients

type KafkaMQ

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

KafkaMQ is backend message queue for MQTT proxy by using Kafka

type KafkaSpec

type KafkaSpec struct {
	Backend []string `yaml:"backend" jsonschema:"required,uniqueItems=true"`
}

KafkaSpec describes Kafka producer

type MQTTProxy

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

MQTTProxy implements MQTT proxy in EG

func (*MQTTProxy) Category

func (mp *MQTTProxy) Category() supervisor.ObjectCategory

Category returns the category of MQTTProxy.

func (*MQTTProxy) Close

func (mp *MQTTProxy) Close()

Close closes MQTTProxy.

func (*MQTTProxy) DefaultSpec

func (mp *MQTTProxy) DefaultSpec() interface{}

DefaultSpec returns the default spec of MQTTProxy.

func (*MQTTProxy) Inherit

func (mp *MQTTProxy) Inherit(superSpec *supervisor.Spec, previousGeneration supervisor.Object)

Inherit inherits previous generation of WebSocketServer.

func (*MQTTProxy) Init

func (mp *MQTTProxy) Init(superSpec *supervisor.Spec)

Init initializes Function.

func (*MQTTProxy) Kind

func (mp *MQTTProxy) Kind() string

Kind returns the kind of MQTTProxy.

func (*MQTTProxy) Status

func (mp *MQTTProxy) Status() *supervisor.Status

Status returns the Status of MQTTProxy.

type Message

type Message struct {
	Topic      string `yaml:"topic"`
	B64Payload string `yaml:"b64Payload"`
	QoS        int    `yaml:"qos"`
}

Message is the message send from broker to client

type Policy

type Policy struct {
	Name       string         `yaml:"name" jsonschema:"required"`
	TopicIndex int            `yaml:"topicIndex" jsonschema:"required"`
	Route      []TopicRe      `yaml:"route" jsonschema:"required"`
	Headers    map[int]string `yaml:"headers" jsonschema:"required"`
}

Policy describes topic map between MQTT topic and Backend MQ topic

type PolicyRe

type PolicyRe struct {
	Name      string `yaml:"name" jsonschema:"required"`
	MatchExpr string `yaml:"matchExpr" jsonschema:"required"`
}

PolicyRe to match right policy to do topic map

type Session

type Session struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Session includes the information about the connect between client and broker, such as topic subscribe, not-send messages, etc.

type SessionInfo

type SessionInfo struct {
	// map subscribe topic to qos
	EGName    string         `yaml:"egName"`
	Name      string         `yaml:"name"`
	Topics    map[string]int `yaml:"topics"`
	ClientID  string         `yaml:"clientID"`
	CleanFlag bool           `yaml:"cleanFlag"`
}

SessionInfo is info about session that will be put into etcd for persistency

type SessionManager

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

SessionManager manage the status of session for clients

type SessionStore

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

SessionStore for session store, key is session clientID, value is session yaml marshal value

type Spec

type Spec struct {
	EGName         string        `yaml:"-"`
	Name           string        `yaml:"-"`
	Port           uint16        `yaml:"port" jsonschema:"required"`
	BackendType    string        `yaml:"backendType" jsonschema:"required"`
	Auth           []Auth        `yaml:"auth" jsonschema:"required"`
	TopicMapper    *TopicMapper  `yaml:"topicMapper" jsonschema:"omitempty"`
	Kafka          *KafkaSpec    `yaml:"kafkaBroker" jsonschema:"omitempty"`
	UseTLS         bool          `yaml:"useTLS" jsonschema:"omitempty"`
	Certificate    []Certificate `yaml:"certificate" jsonschema:"omitempty"`
	TopicCacheSize int           `yaml:"topicCacheSize" jsonschema:"omitempty"`
}

Spec describes the MQTTProxy.

type TopicManager

type TopicManager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

TopicManager to manage topic subscribe and unsubscribe in MQTT

type TopicMapper

type TopicMapper struct {
	MatchIndex int         `yaml:"matchIndex" jsonschema:"required"`
	Route      []*PolicyRe `yaml:"route" jsonschema:"required"`
	Policies   []*Policy   `yaml:"policies" jsonschema:"required"`
}

TopicMapper map MQTT multi-level topic to Kafka topic with headers

type TopicRe

type TopicRe struct {
	Topic string   `yaml:"topic" jsonschema:"required"`
	Exprs []string `yaml:"exprs" jsonschema:"required"`
}

TopicRe to match right topic in given policy

Jump to

Keyboard shortcuts

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