message

package
v0.0.0-...-53883ab Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: MIT Imports: 1 Imported by: 12

Documentation

Index

Constants

View Source
const (
	CONNECT = uint8(iota + 1)
	PUBLISH
	SUBSCRIBE
	UNSUBSCRIBE
	PINGREQ
	PINGRESP
	DISCONNECT

	Contract = uint32(3376684800)
)
View Source
const (
	SubscriberDirect = SubscriberType(iota)
	SubscriberRemote
)

Subscriber types

Variables

This section is empty.

Functions

This section is empty.

Types

type MID

type MID uint32

MID is 32-bit local message identifier

type Message

type Message struct {
	MessageID uint16 `json:"message_id,omitempty"` // The ID of the message
	Topic     []byte `json:"topic,omitempty"`      // The topic of the message
	Payload   []byte `json:"data,omitempty"`       // The payload of the message
	Qos       uint8  `json:"qos,omitempty"`        // The qos of the message
	TTL       int64  `json:"ttl,omitempty"`        // The time-to-live of the message
}

Message represents a message which has to be forwarded or stored.

func (*Message) Size

func (m *Message) Size() int64

Size returns the byte size of the message.

type MessageIds

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

func NewMessageIds

func NewMessageIds() MessageIds

func (*MessageIds) FreeID

func (mids *MessageIds) FreeID(id MID)

func (*MessageIds) GetType

func (mids *MessageIds) GetType(id MID) uint8

func (*MessageIds) NextID

func (mids *MessageIds) NextID(pktType uint8) MID

func (*MessageIds) Reset

func (mids *MessageIds) Reset(id MID)

type Stat

type Stat struct {
	ID      []byte
	Topic   []byte
	Counter int
}

type Stats

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

Stats represents a subscription map.

func NewStats

func NewStats() *Stats

NewStats creates a new container.

func (*Stats) All

func (s *Stats) All() []Stat

All gets the all subscriptions from the stats.

func (*Stats) Decrement

func (s *Stats) Decrement(topic []byte, key string) (last bool, id []byte)

Decrement remove a subscription from the stats.

func (*Stats) Exist

func (s *Stats) Exist(key string) (ok bool)

Get gets subscription from the stats.

func (*Stats) Increment

func (s *Stats) Increment(topic []byte, key string, id []byte) (first bool)

Increment adds the subscription to the stats.

type Subscriber

type Subscriber interface {
	ID() string
	Type() SubscriberType
	SendMessage(*Message) bool
}

Subscriber is a value associated with a subscription.

type SubscriberType

type SubscriberType uint8

SubscriberType represents a type of subscriber

type TopicAnyCount

type TopicAnyCount uint8

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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