message

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PublicTopic = NewTopic("")
	// 用户保留主题 不会进行广播
	InnerTopic = NewTopic("inner")
	// 系统保留主题 不会触发任何注册的回调函数
	SysTopic = NewTopic("sys")
)
View Source
var (
	TopicBase = SysTopic.Child("base")
	// 日志
	TopicSysLog = TopicBase.Child("log")
	// 连接权限验证
	TopicAuth = TopicBase.Child("auth")
)
View Source
var (
	TopicTopic = SysTopic.Child("topic")
	// 订阅指令
	TopicSubscribe = TopicTopic.Child("subscribe")
	// 取消订阅指令
	TopicCancel = TopicTopic.Child("cancel")
	// 取消所有订阅指令
	TopicCancelAll = TopicTopic.Child("cancel_all")
	// 敏感操作 需要通过判定
	TopicSubscribeAll = TopicTopic.Child("subscribe_all/admin")
	TopicGetAllTopics = TopicTopic.Child("get_all_topics/admin")
)
View Source
var (
	TopicNode        = SysTopic.Child("node")
	TopicGetAllNodes = TopicNode.Child("get_all_nodes/admin")
	TopicStopNode    = TopicNode.Child("stop_node/admin")
	TopicNodeStatus  = TopicNode.Child("status/admin")
)
View Source
var (
	TopicCluster = SysTopic.Child("cluster")
	// 三次同步过程建立节点连接
	// 交换id
	TopicClusterID = TopicCluster.Child("id")
	// 通知本身级别
	TopicClusterLevel = TopicCluster.Child("level")
	// 交换cluster节点信息
	TopicClusterInfo = TopicCluster.Child("info")
	// 是否跳转有子节点决定
	TopicClusterRedirect = TopicCluster.Child("redirect")
)
View Source
var (
	ErrNotAllowedTopic = errors.New("this topic is not allowed to subscribe or publish")
	ErrUnformedMsg     = errors.New("unformed Msg")
)
View Source
var (
	MessageTyp_name = map[int32]string{
		0: "Bytes",
		1: "String",
		2: "Int",
		3: "Bool",
		4: "JSON",
		6: "uint",
		5: "float",
	}
	MessageTyp_value = map[string]int32{
		"Bytes":  0,
		"String": 1,
		"Int":    2,
		"Bool":   3,
		"JSON":   4,
		"uint":   6,
		"float":  5,
	}
)

Enum value maps for MessageTyp.

View Source
var InvalidMessage = errors.New("invalid message")
View Source
var InvalidTopic = errors.New("invalid topic")

Functions

func Encode added in v0.2.6

func Encode(t Topic, data interface{}) ([]byte, error)

func IsInnerTopic

func IsInnerTopic(t Topic) bool

func IsPublicTopic

func IsPublicTopic(t Topic) bool

func IsSysTopic

func IsSysTopic(t Topic) bool

Types

type Func

type Func interface{}

A callback which should receives one parameter of type string, int, bool or any valid JSON/Go struct

type FuncBlank

type FuncBlank = func()

type FuncBool

type FuncBool = func(bool)

type FuncBytes

type FuncBytes = func([]byte)

type FuncDefault

type FuncDefault = func(interface{})

type FuncError

type FuncError = func(error)

type FuncInt

type FuncInt = func(int)

type FuncString

type FuncString = func(string)

type Message added in v0.2.6

type Message struct {
	Type     MessageTyp `protobuf:"varint,1,opt,name=type,proto3,enum=message.MessageTyp" json:"type,omitempty"`
	Tag      uint64     `protobuf:"varint,2,opt,name=tag,proto3" json:"tag,omitempty"`
	Source   string     `protobuf:"bytes,3,opt,name=source,proto3" json:"source,omitempty"`
	Target   string     `protobuf:"bytes,4,opt,name=target,proto3" json:"target,omitempty"`
	Data     []byte     `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"`
	UnixTime int64      `protobuf:"varint,6,opt,name=unix_time,json=unixTime,proto3" json:"unix_time,omitempty"`
	// contains filtered or unexported fields
}

func Decode added in v0.2.6

func Decode(b []byte) (*Message, error)

func New added in v0.2.6

func New() *Message

func (*Message) Body added in v0.2.6

func (x *Message) Body() interface{}

func (*Message) Descriptor deprecated added in v0.2.6

func (*Message) Descriptor() ([]byte, []int)

Deprecated: Use Message.ProtoReflect.Descriptor instead.

func (*Message) GetData added in v0.2.6

func (x *Message) GetData() []byte

func (*Message) GetSource added in v0.2.6

func (x *Message) GetSource() string

func (*Message) GetTag added in v0.2.6

func (x *Message) GetTag() uint64

func (*Message) GetTarget added in v0.2.6

func (x *Message) GetTarget() string

func (*Message) GetType added in v0.2.6

func (x *Message) GetType() MessageTyp

func (*Message) GetUnixTime added in v0.2.6

func (x *Message) GetUnixTime() int64

func (*Message) ProtoMessage added in v0.2.6

func (*Message) ProtoMessage()

func (*Message) ProtoReflect added in v0.2.6

func (x *Message) ProtoReflect() protoreflect.Message

func (*Message) Release added in v0.2.6

func (x *Message) Release()

func (*Message) Reset added in v0.2.6

func (x *Message) Reset()

func (*Message) String added in v0.2.6

func (x *Message) String() string

type MessageTyp added in v0.2.6

type MessageTyp int32
const (
	Message_Bytes  MessageTyp = 0
	Message_String MessageTyp = 1
	Message_Int    MessageTyp = 2
	Message_Bool   MessageTyp = 3
	Message_JSON   MessageTyp = 4
	Message_uint   MessageTyp = 6
	Message_float  MessageTyp = 5
)

func (MessageTyp) Descriptor added in v0.2.6

func (MessageTyp) Descriptor() protoreflect.EnumDescriptor

func (MessageTyp) Enum added in v0.2.6

func (x MessageTyp) Enum() *MessageTyp

func (MessageTyp) EnumDescriptor deprecated added in v0.2.6

func (MessageTyp) EnumDescriptor() ([]byte, []int)

Deprecated: Use MessageTyp.Descriptor instead.

func (MessageTyp) Number added in v0.2.6

func (x MessageTyp) Number() protoreflect.EnumNumber

func (MessageTyp) String added in v0.2.6

func (x MessageTyp) String() string

func (MessageTyp) Type added in v0.2.6

type RawFunc added in v0.2.6

type RawFunc = func(*Message)

type Subscriber

type Subscriber struct {
	CallPath string
	utils.FastLocker
	// contains filtered or unexported fields
}

func (*Subscriber) Cancel

func (s *Subscriber) Cancel()

func (*Subscriber) Do

func (s *Subscriber) Do(apd interface{})

func (*Subscriber) SetMax

func (s *Subscriber) SetMax(i uint)

func (*Subscriber) SetOnce

func (s *Subscriber) SetOnce()

func (*Subscriber) Valid

func (s *Subscriber) Valid() bool

type SubscriberList

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

func NewSubscriberList

func NewSubscriberList() *SubscriberList

func (*SubscriberList) Add

func (l *SubscriberList) Add(cb Func) *Subscriber

func (*SubscriberList) Len

func (l *SubscriberList) Len() int

func (*SubscriberList) Range

func (l *SubscriberList) Range(cb func(*Subscriber))

func (*SubscriberList) RemoveInvalid added in v0.2.8

func (l *SubscriberList) RemoveInvalid()

type Topic

type Topic interface {
	String() string
	Bytes() []byte
	FirstFragment() string
	Fragment(int) string
	Since(int) string
	Child(string) Topic
	IsChildOf(p Topic) bool
	Len() int
}

func NewTopic

func NewTopic(t string) Topic

Jump to

Keyboard shortcuts

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