broker

package
v0.0.0-...-4f2055d Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: Apache-2.0 Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LOCAL  = 0
	REMOTE = 1
)
View Source
const (
	Connected    = 1
	Disconnected = 2
)
View Source
const (
	// EventTypeNew event type new
	EventTypeNew = EvtType(0)
	// EventTypeUpdate event type update
	EventTypeUpdate = EvtType(1)
	// EventTypeDelete event type delete
	EventTypeDelete = EvtType(2)
)
View Source
const (
	// EventSrcNode node event
	EventSrcNode = EvtSrc(0)
	// EventSrcClient client event
	EventSrcClient = EvtSrc(1)
	// EventSrcSubscribe subscribe event
	EventSrcSubscription = EvtSrc(2)
	EventSrcBridge       = EvtSrc(3)
	EventSrcUser         = EvtSrc(4)
	EventSrcAcl          = EvtSrc(5)
)
View Source
const (
	// ACCEPT_MIN_SLEEP is the minimum acceptable sleep times on temporary errors.
	ACCEPT_MIN_SLEEP = 100 * time.Millisecond
	// ACCEPT_MAX_SLEEP is the maximum acceptable sleep times on temporary errors
	ACCEPT_MAX_SLEEP = 10 * time.Second
	// DEFAULT_ROUTE_CONNECT Route solicitation intervals.
	DEFAULT_ROUTE_CONNECT = 5 * time.Second
	// DEFAULT_TLS_TIMEOUT
	DEFAULT_TLS_TIMEOUT = 5 * time.Second
)
View Source
const (
	CONNECT = uint8(iota + 1)
	CONNACK
	PUBLISH
	PUBACK
	PUBREC
	PUBREL
	PUBCOMP
	SUBSCRIBE
	SUBACK
	UNSUBSCRIBE
	UNSUBACK
	PINGREQ
	PINGRESP
	DISCONNECT
)
View Source
const (
	QosAtMostOnce byte = iota
	QosAtLeastOnce
	QosExactlyOnce
	QosFailure = 0x80
)
View Source
const (
	// DefaultTimeout default timeout
	DefaultTimeout = time.Second * 3
	// DefaultRequestTimeout default request timeout
	DefaultRequestTimeout = 10 * time.Second
	// DefaultSlowRequestTime default slow request time
	DefaultSlowRequestTime = time.Second * 1
)
View Source
const (
	Version = "v0.1"
)

Variables

View Source
var (
	// TICKER ticket
	TICKER = time.Second * 3
	// TTL timeout
	TTL = int64(5)
)

Functions

func GenUniqueId

func GenUniqueId() string

func InitHTTPMoniter

func InitHTTPMoniter(b *Broker)

func ProcessMessage

func ProcessMessage(msg *Message)

Types

type Broker

type Broker struct {
	// contains filtered or unexported fields
}
var BROKER *Broker

func NewBroker

func NewBroker(config *config.GlobalConfig) (*Broker, error)

func (*Broker) Bridge

func (b *Broker) Bridge(e *bridge.Elements)

func (*Broker) CheckConnectAuth

func (b *Broker) CheckConnectAuth(clientID, username, password string) bool

func (*Broker) DisConnClientByClientId

func (b *Broker) DisConnClientByClientId(clientId string)

func (*Broker) PublishMessage

func (b *Broker) PublishMessage(packet *packets.PublishPacket)

func (*Broker) Start

func (b *Broker) Start()

func (*Broker) StartClientListening

func (b *Broker) StartClientListening(Tls bool)

func (*Broker) SubmitWork

func (b *Broker) SubmitWork(clientId string, msg *Message)

type Cluster

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

func (*Cluster) AddORUpdateAcl

func (c *Cluster) AddORUpdateAcl(obj *model.Acl)

func (*Cluster) AddORUpdateBridge

func (c *Cluster) AddORUpdateBridge(key string, value string)

func (*Cluster) AddORUpdateClient

func (c *Cluster) AddORUpdateClient(obj *model.Client)

func (*Cluster) AddORUpdateNode

func (c *Cluster) AddORUpdateNode(node *model.Node) error

func (*Cluster) AddORUpdateSubscription

func (c *Cluster) AddORUpdateSubscription(subscription *model.Subscription)

func (*Cluster) AddORUpdateUser

func (c *Cluster) AddORUpdateUser(obj *model.User)

func (*Cluster) GetAcl

func (c *Cluster) GetAcl(id string) (*model.Acl, error)

func (*Cluster) GetAcls

func (c *Cluster) GetAcls() (map[string]*model.Acl, error)

func (*Cluster) GetBridge

func (c *Cluster) GetBridge(name string) (string, error)

func (*Cluster) GetBridges

func (c *Cluster) GetBridges() (map[string]string, error)

func (*Cluster) GetClient

func (c *Cluster) GetClient(id string) (*model.Client, error)

func (*Cluster) GetClients

func (c *Cluster) GetClients() (map[string]*model.Client, error)

func (*Cluster) GetNode

func (c *Cluster) GetNode(id string) (*model.Node, error)

func (*Cluster) GetNodes

func (c *Cluster) GetNodes() (map[string]*model.Node, error)

func (*Cluster) GetSubscription

func (c *Cluster) GetSubscription(id string) (*model.Subscription, error)

func (*Cluster) GetSubscriptions

func (c *Cluster) GetSubscriptions() (map[string]*model.Subscription, error)

func (*Cluster) GetUser

func (c *Cluster) GetUser(name string) (*model.User, error)

func (*Cluster) GetUsers

func (c *Cluster) GetUsers() (map[string]*model.User, error)

func (*Cluster) LoadAcls

func (c *Cluster) LoadAcls()

func (*Cluster) LoadBridges

func (c *Cluster) LoadBridges()

func (*Cluster) LoadClients

func (c *Cluster) LoadClients()

func (*Cluster) LoadSubscriptions

func (c *Cluster) LoadSubscriptions()

func (*Cluster) LoadUsers

func (c *Cluster) LoadUsers()

func (*Cluster) RegistryNode

func (c *Cluster) RegistryNode(node *model.Node, ttl int64)

func (*Cluster) RemoveAcl

func (c *Cluster) RemoveAcl(id string)

func (*Cluster) RemoveBridge

func (c *Cluster) RemoveBridge(key string)

func (*Cluster) RemoveClient

func (c *Cluster) RemoveClient(id string)

func (*Cluster) RemoveNode

func (c *Cluster) RemoveNode(id string) error

func (*Cluster) RemoveSubscription

func (c *Cluster) RemoveSubscription(subscription *model.Subscription)

func (*Cluster) RemoveUser

func (c *Cluster) RemoveUser(obj *model.User)

func (*Cluster) Start

func (c *Cluster) Start()

func (*Cluster) StoreAddORUpdateAcl

func (c *Cluster) StoreAddORUpdateAcl(obj *model.Acl) error

func (*Cluster) StoreAddORUpdateBridge

func (c *Cluster) StoreAddORUpdateBridge(key string, value string) error

func (*Cluster) StoreAddORUpdateClient

func (c *Cluster) StoreAddORUpdateClient(obj *model.Client) error

func (*Cluster) StoreAddORUpdateSubscription

func (c *Cluster) StoreAddORUpdateSubscription(subscription *model.Subscription) error

func (*Cluster) StoreAddORUpdateUser

func (c *Cluster) StoreAddORUpdateUser(obj *model.User) error

func (*Cluster) StoreRemoveAcl

func (c *Cluster) StoreRemoveAcl(id string) error

func (*Cluster) StoreRemoveBridge

func (c *Cluster) StoreRemoveBridge(key string) error

func (*Cluster) StoreRemoveClient

func (c *Cluster) StoreRemoveClient(id string) error

func (*Cluster) StoreRemoveSubscription

func (c *Cluster) StoreRemoveSubscription(topic string, clientID string) error

func (*Cluster) StoreRemoveUser

func (c *Cluster) StoreRemoveUser(user string) error

type Evt

type Evt struct {
	Src   EvtSrc
	Type  EvtType
	Key   string
	Value interface{}
}

Evt event

type EvtSrc

type EvtSrc int

EvtSrc event src

type EvtType

type EvtType int

EvtType event type

type InflightStatus

type InflightStatus uint8
const (
	Publish InflightStatus = 0
	Pubrel  InflightStatus = 1
)

type Message

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

type Router

type Router interface {
	Forward(nodeID string, data *model.Forward) error
	Receive()
}

type Store

type Store interface {
	Raw() interface{}
	Txn() interface{}
	Open() error
	Put(key string, value interface{}) error
	Get(key string) (interface{}, error)
	All(prefix string) (interface{}, error)
	Del(key string) error
	Close() error
	Reset() error
}

Directories

Path Synopsis
lib

Jump to

Keyboard shortcuts

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