cluster

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypPublish = 100
	TypConnect = 100 + iota
	TypDisconnect
)

Variables

View Source
var (
	ErrInvalidMessageData = packets.Code{Code: 0xD0, Reason: "invalid cluster message"}
	ErrInvalidBroker      = packets.Code{Code: 0xD1, Reason: "invalid broker, broker must not be  nil"}
)

Functions

This section is empty.

Types

type Cluster

type Cluster struct {
	Opt      *Opt
	Event    *Event
	Delegate *Delegate
	List     *memberlist.Memberlist
	Queue    *memberlist.TransmitLimitedQueue
	Hook     *Hook
}

func (*Cluster) Broadcast

func (c *Cluster) Broadcast(data []byte) error

func (*Cluster) Broker

func (c *Cluster) Broker() *mqttor.Server

func (*Cluster) GetHook

func (c *Cluster) GetHook() *Hook

func (*Cluster) Name

func (c *Cluster) Name() string

func (*Cluster) ProcessMessage

func (c *Cluster) ProcessMessage(data []byte) error

func (*Cluster) Publish

func (c *Cluster) Publish(topic string, payload []byte, retain bool, qos byte) error

func (*Cluster) Serve

func (c *Cluster) Serve() error

func (*Cluster) Stop

func (c *Cluster) Stop() error

type Delegate

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

func NewDelegate

func NewDelegate(c *Cluster) *Delegate

func (*Delegate) GetBroadcasts

func (d *Delegate) GetBroadcasts(overhead, limit int) [][]byte

func (*Delegate) LocalState

func (d *Delegate) LocalState(join bool) []byte

func (*Delegate) MergeRemoteState

func (d *Delegate) MergeRemoteState(buf []byte, join bool)

func (*Delegate) NodeMeta

func (d *Delegate) NodeMeta(limit int) []byte

func (*Delegate) NotifyMsg

func (d *Delegate) NotifyMsg(msg []byte)

type Event

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

func NewEvent

func NewEvent(c *Cluster) *Event

func (*Event) NotifyJoin

func (e *Event) NotifyJoin(node *memberlist.Node)

func (*Event) NotifyLeave

func (e *Event) NotifyLeave(node *memberlist.Node)

func (*Event) NotifyUpdate

func (e *Event) NotifyUpdate(node *memberlist.Node)

type Hook

type Hook struct {
	mqttor.HookBase

	Log *zerolog.Logger
	// contains filtered or unexported fields
}

Hook is a debugging hook which logs additional low-level information from the server.

func NewHook

func NewHook(c *Cluster) *Hook

func (*Hook) ID

func (h *Hook) ID() string

func (*Hook) Init

func (h *Hook) Init(config any) error

Init is called when the hook is initialized.

func (*Hook) OnDisconnect

func (h *Hook) OnDisconnect(cl *mqttor.Client, err error, expire bool)

func (*Hook) OnPublish

func (h *Hook) OnPublish(cl *mqttor.Client, pk packets.Packet) (packets.Packet, error)

func (*Hook) OnSessionEstablished

func (h *Hook) OnSessionEstablished(cl *mqttor.Client, pk packets.Packet)

func (*Hook) OnWillSent

func (h *Hook) OnWillSent(cl *mqttor.Client, pk packets.Packet)

func (*Hook) Provides

func (h *Hook) Provides(b byte) bool

Provides indicates which hook methods this hook provides.

func (*Hook) SetOpts

func (h *Hook) SetOpts(l *zerolog.Logger, opts *mqttor.HookOptions)

type Msg

type Msg struct {
	Typ     byte
	From    string
	Payload []byte
}

func NewMsg

func NewMsg(from string, typ byte, payload []byte) *Msg

func (*Msg) Decode

func (m *Msg) Decode(data []byte) error

func (*Msg) Encode

func (m *Msg) Encode() []byte

type Opt

type Opt struct {
	Name          string
	Addr          string
	AdvertiseAddr string
	Members       string
	Log           *zerolog.Logger
	Broker        *mqttor.Server
}

func DefaultOption

func DefaultOption() *Opt

type OptItem

type OptItem func(opt *Opt)

func OptAddr

func OptAddr(addr string) OptItem

func OptAdvertiseAddr added in v1.0.2

func OptAdvertiseAddr(addr string) OptItem

func OptBroker

func OptBroker(b *mqttor.Server) OptItem

func OptLog

func OptLog(log *zerolog.Logger) OptItem

func OptMembers

func OptMembers(members string) OptItem

func OptName

func OptName(name string) OptItem

type Options

type Options struct {
}

Options contains configuration settings for the debug output.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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