admin

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Online ...
	Online = "online"
	// Offline ...
	Offline = "offline"
)
View Source
const Name = "admin"

Name ...

Variables

View Source
var (
	// ErrInvalidTopicFilter ...
	ErrInvalidTopicFilter = errors.New("invalid topic filter")
	// ErrInvalidQos ...
	ErrInvalidQos = errors.New("invalid Qos")
	// ErrInvalidClientID ...
	ErrInvalidClientID = errors.New("invalid clientID")
	// ErrInvalidUtf8String ...
	ErrInvalidUtf8String = errors.New("invalid utf-8 string")
	// ErrNotFound ...
	ErrNotFound = errors.New("not found")
)

Functions

func GetOffsetN

func GetOffsetN(page, pageSize uint) (offset, n uint)

GetOffsetN ...

Types

type Admin

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

Admin ...

func New

func New() *Admin

New ...

func (*Admin) CloseClient

func (a *Admin) CloseClient(clientId string) (err error)

CloseClient ...

func (*Admin) GetClient

func (a *Admin) GetClient(clientId string) (client *ClientInfo, err error)

GetClient ...

func (*Admin) GetClients

func (a *Admin) GetClients(limit, offset uint) (list []*ClientInfo, total uint32, err error)

GetClients ...

func (*Admin) GetSession

func (a *Admin) GetSession(clientId string) (session *SessionInfo, err error)

GetSession ...

func (*Admin) GetSessions

func (a *Admin) GetSessions(limit, offset uint) (list []*SessionInfo, total int, err error)

GetSessions ...

func (*Admin) GetSubscriptions

func (a *Admin) GetSubscriptions(clientId string, limit, offset uint) (list []*SubscriptionInfo, total int, err error)

GetSubscriptions ...

func (*Admin) HookWrapper

func (a *Admin) HookWrapper() server.HookWrapper

HookWrapper ...

func (*Admin) Load

func (a *Admin) Load(service server.Server) error

Load ...

func (*Admin) Name

func (a *Admin) Name() string

Name ...

func (*Admin) OnClosedWrapper

func (a *Admin) OnClosedWrapper(pre server.OnClosed) server.OnClosed

OnClosedWrapper refresh the client when session resumed

func (*Admin) OnSessionCreatedWrapper

func (a *Admin) OnSessionCreatedWrapper(pre server.OnSessionCreated) server.OnSessionCreated

OnSessionCreatedWrapper store the client when session created

func (*Admin) OnSessionResumedWrapper

func (a *Admin) OnSessionResumedWrapper(pre server.OnSessionResumed) server.OnSessionResumed

OnSessionResumedWrapper refresh the client when session resumed

func (*Admin) OnSessionTerminatedWrapper

func (a *Admin) OnSessionTerminatedWrapper(pre server.OnSessionTerminated) server.OnSessionTerminated

OnSessionTerminated remove the client when session terminated

func (*Admin) OnSubscribedWrapper

func (a *Admin) OnSubscribedWrapper(pre server.OnSubscribed) server.OnSubscribed

OnSubscribedWrapper store the subscription

func (*Admin) OnUnsubscribedWrapper

func (a *Admin) OnUnsubscribedWrapper(pre server.OnUnsubscribed) server.OnUnsubscribed

OnUnsubscribedWrapper remove the subscription

func (*Admin) Publish

func (a *Admin) Publish(topic string, qos int, payload []byte, retain bool) (err error)

Publish ...

func (*Admin) SearchTopic

func (a *Admin) SearchTopic(query string) (result []*SubscriptionInfo, err error)

SearchTopic ...

func (*Admin) Subscribe

func (a *Admin) Subscribe(clientId, topic string, qos int) (err error)

Subscribe ...

func (*Admin) Unload

func (a *Admin) Unload() error

Unload ...

func (*Admin) Unsubscribe

func (a *Admin) Unsubscribe(clientId, topic string) (err error)

Unsubscribe ...

type ClientInfo

type ClientInfo struct {
	ClientID             string     `json:"client_id"`
	Username             string     `json:"username"`
	KeepAlive            uint16     `json:"keep_alive"`
	Version              int32      `json:"version"`
	WillRetain           bool       `json:"will_retain"`
	WillQos              uint8      `json:"will_qos"`
	WillTopic            string     `json:"will_topic"`
	WillPayload          string     `json:"will_payload"`
	RemoteAddr           string     `json:"remote_addr"`
	LocalAddr            string     `json:"local_addr"`
	SubscriptionsCurrent uint32     `json:"subscriptions_current"`
	SubscriptionsTotal   uint32     `json:"subscriptions_total"`
	PacketsReceivedBytes uint64     `json:"packets_received_bytes"`
	PacketsReceivedNums  uint64     `json:"packets_received_nums"`
	PacketsSendBytes     uint64     `json:"packets_send_bytes"`
	PacketsSendNums      uint64     `json:"packets_send_nums"`
	MessageDropped       uint64     `json:"message_dropped"`
	InflightLen          uint32     `json:"inflight_len"`
	QueueLen             uint32     `json:"queue_len"`
	ConnectedAt          time.Time  `json:"connected_at"`
	DisconnectedAt       *time.Time `json:"disconnected_at"`
}

ClientInfo represents the client information

type Indexer

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

Indexer provides a index for a ordered list that supports queries in O(1). All methods are not concurrency-safe.

func NewIndexer

func NewIndexer() *Indexer

NewIndexer is the constructor of Indexer.

func (*Indexer) GetByID

func (i *Indexer) GetByID(id string) *list.Element

GetByID returns the value for the given id. Return nil if not found. Notice: Any access to the return *list.Element also require the mutex, because the Set method can modify the Value for *list.Element when updating the Value for the same id. If the caller needs the Value in *list.Element, it must get the Value before the next Set is called.

func (*Indexer) Iterate

func (i *Indexer) Iterate(fn func(elem *list.Element), offset, n uint)

Iterate iterates at most n elements in the list begin from offset. Notice: Any access to the *list.Element in fn also require the mutex, because the Set method can modify the Value for *list.Element when updating the Value for the same id. If the caller needs the Value in *list.Element, it must get the Value before the next Set is called.

func (*Indexer) Len

func (i *Indexer) Len() int

Len returns the length of list.

func (*Indexer) Remove

func (i *Indexer) Remove(id string) *list.Element

Remove removes and returns the value for the given id. Return nil if not found.

func (*Indexer) Set

func (i *Indexer) Set(id string, value interface{})

Set sets the value for the id.

type SessionInfo

type SessionInfo struct {
	ClientID              string     `json:"client_id"`
	Status                string     `json:"status"`
	CleanSession          bool       `json:"clean_session"`
	Subscriptions         uint64     `json:"subscriptions"`
	MaxInflight           uint16     `json:"max_inflight"`
	InflightLen           uint64     `json:"inflight_len"`
	MaxMsgQueue           int        `json:"max_msg_queue"`
	MsgQueueLen           uint64     `json:"msg_queue_len"`
	AwaitRelLen           uint64     `json:"await_rel_len"`
	Qos0MsgDroppedTotal   uint64     `json:"qos0_msg_dropped_total"`
	Qos1MsgDroppedTotal   uint64     `json:"qos1_msg_dropped_total"`
	Qos2MsgDroppedTotal   uint64     `json:"qos2_msg_dropped_total"`
	Qos0MsgDeliveredTotal uint64     `json:"qos0_msg_delivered_total"`
	Qos1MsgDeliveredTotal uint64     `json:"qos1_msg_delivered_total"`
	Qos2MsgDeliveredTotal uint64     `json:"qos2_msg_delivered_total"`
	ConnectedAt           *time.Time `json:"connected_at"`
	DisconnectedAt        *time.Time `json:"disconnected_at"`
}

SessionInfo represents the session information

type SubscriptionInfo

type SubscriptionInfo struct {
	Id                uint32 `json:"id"`
	ClientID          string `json:"client_id"`
	TopicName         string `json:"topic_name"`
	Name              string `json:"name"`
	Qos               uint32 `json:"qos"`
	NoLocal           bool   `json:"no_local"`
	RetainAsPublished bool   `json:"retain_as_published"`
	RetainHandling    uint32 `json:"retain_handling"`
}

SubscriptionInfo represents the subscription information

Jump to

Keyboard shortcuts

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