Documentation ¶
Index ¶
- Variables
- func Encode(t Topic, data interface{}) ([]byte, error)
- func IsInnerTopic(t Topic) bool
- func IsPublicTopic(t Topic) bool
- func IsSysTopic(t Topic) bool
- type Func
- type FuncBlank
- type FuncBool
- type FuncBytes
- type FuncDefault
- type FuncError
- type FuncInt
- type FuncString
- type Message
- func (x *Message) Body() interface{}
- func (*Message) Descriptor() ([]byte, []int)deprecated
- func (x *Message) GetData() []byte
- func (x *Message) GetSource() string
- func (x *Message) GetTag() uint64
- func (x *Message) GetTarget() string
- func (x *Message) GetType() MessageTyp
- func (x *Message) GetUnixTime() int64
- func (*Message) ProtoMessage()
- func (x *Message) ProtoReflect() protoreflect.Message
- func (x *Message) Release()
- func (x *Message) Reset()
- func (x *Message) String() string
- type MessageTyp
- type RawFunc
- type Subscriber
- type SubscriberList
- type Topic
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 File_msg_proto protoreflect.FileDescriptor
View Source
var InvalidMessage = errors.New("invalid message")
View Source
var InvalidTopic = errors.New("invalid topic")
Functions ¶
func IsInnerTopic ¶
func IsPublicTopic ¶
func IsSysTopic ¶
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 FuncDefault ¶
type FuncDefault = func(interface{})
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 (*Message) Descriptor
deprecated
added in
v0.2.6
func (*Message) GetType ¶ added in v0.2.6
func (x *Message) GetType() MessageTyp
func (*Message) GetUnixTime ¶ added in v0.2.6
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
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
func (MessageTyp) Type() protoreflect.EnumType
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()
Click to show internal directories.
Click to hide internal directories.