mqttproxy

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package mqttproxy implements the MQTTProxy.

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.CategoryTrafficGate

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

Variables

This section is empty.

Functions

This section is empty.

Types

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 `json:"name" jsonschema:"required"`
	Cert string `json:"cert" jsonschema:"required"`
	Key  string `json:"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

func (*Client) ClientID

func (c *Client) ClientID() string

ClientID return client id of Client

func (*Client) Delete

func (c *Client) Delete(key interface{})

Delete delete key-value pair in Client kv map

func (*Client) Load

func (c *Client) Load(key interface{}) (value interface{}, ok bool)

Load load value keep in Client kv map

func (*Client) Store

func (c *Client) Store(key interface{}, value interface{})

Store store key-value pair in Client kv map

func (*Client) UserName

func (c *Client) UserName() string

UserName return username of Client

type ClientInfo

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

ClientInfo is basic information 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 HTTPSession

type HTTPSession struct {
	SessionID string `json:"sessionID"`
	Topic     string `json:"topic"`
}

HTTPSession is json data used for session related operations, like get all sessions and delete some sessions

type HTTPSessions

type HTTPSessions struct {
	Sessions []*HTTPSession `json:"sessions"`
}

HTTPSessions is json data used for session related operations, like get all sessions and delete some sessions

type Limiter

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

Limiter is a rate limiter for MQTTProxy

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, muxMapper context.MuxMapper)

Inherit inherits previous generation of MQTTProxy.

func (*MQTTProxy) Init

func (mp *MQTTProxy) Init(superSpec *supervisor.Spec, muxMapper context.MuxMapper)

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 `json:"topic"`
	B64Payload string `json:"b64Payload"`
	QoS        int    `json:"qos"`
}

Message is the message send from broker to client

type PacketType

type PacketType string

PacketType is mqtt packet type

const (
	// Connect is connect type of MQTT packet
	Connect PacketType = "Connect"

	// Disconnect is disconnect type of MQTT packet
	Disconnect PacketType = "Disconnect"

	// Publish is publish type of MQTT packet
	Publish PacketType = "Publish"

	// Subscribe is subscribe type of MQTT packet
	Subscribe PacketType = "Subscribe"

	// Unsubscribe is unsubscribe type of MQTT packet
	Unsubscribe PacketType = "Unsubscribe"
)

type RateLimit

type RateLimit struct {
	RequestRate int `json:"requestRate,omitempty"`
	BytesRate   int `json:"bytesRate,omitempty"`
	TimePeriod  int `json:"timePeriod,omitempty"`
}

RateLimit describes rate limit for connection or publish. requestRate: max allowed request in time period timePeriod: max allowed bytes in time period timePeriod: time of seconds to count requestRate and bytesRate, default 1 second

type Rule

type Rule struct {
	When     *When  `json:"when,omitempty"`
	Pipeline string `json:"pipeline,omitempty"`
}

Rule used to route MQTT packets to different pipelines

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 SessionCacheManager

type SessionCacheManager interface {
	// contains filtered or unexported methods
}

SessionCacheManager is the interface for session cache. SessionCache is used in broker mode only. It stores session info of clients from different easegress instances. It update topic manager when session info of is updated.

type SessionInfo

type SessionInfo struct {
	// map subscribe topic to qos
	EGName    string         `json:"egName"`
	Name      string         `json:"name"`
	Topics    map[string]int `json:"topics"`
	ClientID  string         `json:"clientID"`
	CleanFlag bool           `json:"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 json marshal value

type Spec

type Spec struct {
	EGName               string        `json:"-"`
	Name                 string        `json:"-"`
	Port                 uint16        `json:"port" jsonschema:"required"`
	UseTLS               bool          `json:"useTLS,omitempty"`
	Certificate          []Certificate `json:"certificate,omitempty"`
	TopicCacheSize       int           `json:"topicCacheSize,omitempty"`
	MaxAllowedConnection int           `json:"maxAllowedConnection,omitempty"`
	ConnectionLimit      *RateLimit    `json:"connectionLimit,omitempty"`
	ClientPublishLimit   *RateLimit    `json:"clientPublishLimit,omitempty"`
	Rules                []*Rule       `json:"rules,omitempty"`
	BrokerMode           bool          `json:"brokerMode,omitempty"`
	// unit is second, default is 30s
	RetryInterval int `yaml:"retryInterval,omitempty"`
}

Spec describes the MQTTProxy.

type TopicManager

type TopicManager interface {
	// contains filtered or unexported methods
}

TopicManager is the interface of a topic manager.

type When

type When struct {
	PacketType PacketType `json:"packetType,omitempty"`
}

When is used to check if MQTT packet match this pipeline

Jump to

Keyboard shortcuts

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