broker

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

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker struct {
	Root      *TopicNode
	SessionMg *SessionManager
	// contains filtered or unexported fields
}

func NewBroker

func NewBroker(b *BrokerConfigs) *Broker

NewBroker inicializa um novo corretor MQTT com um nó raiz

func (*Broker) AddSubscribeTopicNode

func (b *Broker) AddSubscribeTopicNode(topic string, id string, subs *SubscriberConfig, topicNode chan bool) error

func (*Broker) AddTopic

func (b *Broker) AddTopic(topic string, topicCfg *TopicConfig, topicReady chan bool)

func (*Broker) GetTopicNode

func (b *Broker) GetTopicNode(topic string) *TopicNode

func (*Broker) IncMsgCount

func (b *Broker) IncMsgCount(topic string) error

func (*Broker) NotifyAllSubscribers

func (b *Broker) NotifyAllSubscribers(topic string, topicReady chan bool)

func (*Broker) PrintAllTree

func (b *Broker) PrintAllTree()

PrintTree imprime a árvore de tópicos a partir do nó fornecido

func (*Broker) Start

func (b *Broker) Start()

type BrokerConfigs

type BrokerConfigs struct {
	Name           string
	Address        string
	TypeConnection connection.TypeConnection
}

Broker representa a entidade do corretor MQTT

type Session

type Session struct {
	Timestamp time.Time
	// contains filtered or unexported fields
}

Session representa uma sessão MQTT

type SessionConfig

type SessionConfig struct {
	Id        string
	KeepAlive int16
	Clean     bool
	// contains filtered or unexported fields
}

session.go

type SessionManager

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

SessionManager gerencia sessões MQTT

func NewSessionManager

func NewSessionManager() *SessionManager

NewSessionManager creates a new SessionManager

func (*SessionManager) AddSession

func (sm *SessionManager) AddSession(sessionCfg *SessionConfig, chSession chan *Session)

AddSession adds a new session to the top of the list

func (*SessionManager) CheckSession

func (sm *SessionManager) CheckSession(partition *SessionPartition, wg *sync.WaitGroup, currentTimestamp *time.Time)

func (*SessionManager) CheckSessionTimeouts

func (sm *SessionManager) CheckSessionTimeouts() error

CheckSessionTimeouts verifica e remove sessões cujo tempo limite expirou

func (*SessionManager) DebugPrint

func (sm *SessionManager) DebugPrint()

func (*SessionManager) Exist

func (sm *SessionManager) Exist(id string) bool

func (*SessionManager) GetSessionCount

func (sm *SessionManager) GetSessionCount() int

func (*SessionManager) RemoveSession

func (sm *SessionManager) RemoveSession(id string, keepAlive int16)

RemoveSession removes sessions from the map and updates pointers

func (*SessionManager) UpdateSession

func (sm *SessionManager) UpdateSession(sessionCfg *SessionConfig, chSession chan *Session)

UpdateSession moves the updated session to the top of the list

type SessionPartition

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

type SubscriberConfig

type SubscriberConfig struct {
	Identifier []byte
	Qos        int
	// contains filtered or unexported fields
}

type TopicConfig

type TopicConfig struct {
	Payload      string `json:"payload"`
	Qos          int    `json:"qos"`
	Retained     bool   `json:"retained"`     // Indica se a mensagem é retida ou não
	SecurityRule string `json:"securityRule"` // Regra de segurança aplicada ao tópico
}

type TopicNode

type TopicNode struct {
	Name             string                       `json:"name"`
	Topic            string                       `json:"topic"`
	TopicConfig      *TopicConfig                 `json:"topicCfg,omitempty"`
	Subscribers      map[string]*SubscriberConfig `json:"subscribers"` // Lista de sub-tópicos associados a este tópico
	MessageCount     int                          `json:"messageCount"`
	SubscribersCount int                          `json:"subscribersCount"`
	Children         map[string]*TopicNode        `json:"children,omitempty"` //map[string]*TopicNode
	// contains filtered or unexported fields
}

Topic.go

Jump to

Keyboard shortcuts

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