message

package
v0.2.2 Latest Latest
Warning

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

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

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 int32

MID is 32-bit local message identifier

type Message

type Message struct {
	MessageID    uint16 `json:"message_id,omitempty"`    // The ID of the message
	DeliveryMode uint8  `json:"delivery_mode,omitempty"` // The delivery mode of the message
	Delay        int32  `json:"delay,omitempty"`         // The time in milliseconds to delay the delivery of the message
	Topic        string `json:"topic,omitempty"`         // The topic of the message
	Payload      []byte `json:"data,omitempty"`          // The payload 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) utp.MessageType

func (*MessageIds) NextID

func (mids *MessageIds) NextID(pktType utp.MessageType) MID

func (*MessageIds) Reset

func (mids *MessageIds) Reset()

func (*MessageIds) ResumeID

func (mids *MessageIds) ResumeID(id MID)

type Stat

type Stat struct {
	ID      []byte
	Topic   string
	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 string, 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 string, 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