Versions in this module Expand all Collapse all v1 v1.0.2 Jan 27, 2022 v1.0.1 Dec 1, 2021 Changes in this version + const BucketsStrategy + const BucketsWithFactorStrategy + const CorePeersStrategy + const DefaultStrategy + const MessageVersion1 + const MessageVersion2 + const MessageVersion3 + const NearestBucketStrategy + var ErrChannelBlock = errors.New("channel block") + var ErrHandlerError = errors.New("handler error") + var ErrMessageChecksum = errors.New("verify checksum error") + var ErrMessageDecompress = errors.New("decompress error") + var ErrMessageEmpty = errors.New("message empty") + var ErrMessageHandled = errors.New("message handled") + var ErrMessageUnmarshal = errors.New("message unmarshal error") + var ErrNotRegister = errors.New("message not register") + var ErrRegistered = errors.New("subscriber already registered") + var ErrResponseNil = errors.New("handler response is nil") + var ErrStreamNil = errors.New("stream is nil") + var ErrStreamSendError = errors.New("send response error") + var ErrSubscriber = errors.New("subscribe error") + func Checksum(msg *pb.XuperMessage) uint32 + func Compress(msg *pb.XuperMessage) *pb.XuperMessage + func Decompress(msg *pb.XuperMessage) ([]byte, error) + func GenerateKeyPairWithPath(path string) error + func GenerateNetKeyFromPemKey(path string) error + func GeneratePemKeyFromNetKey(path string) error + func GenerateUniqueRandList(size int, max int) []int + func GetKeyPairFromPath(path string) (crypto.PrivKey, error) + func GetPeerIDByAddress(peerAddr string) (peer.ID, error) + func GetPeerIDFromPath(path string) (string, error) + func GetPemKeyPairFromPath(path string) (crypto.PrivKey, error) + func GetRespMessageType(msgType pb.XuperMessage_MessageType) pb.XuperMessage_MessageType + func MessageKey(msg *pb.XuperMessage) string + func NewMessage(typ pb.XuperMessage_MessageType, message proto.Message, opts ...MessageOption) *pb.XuperMessage + func NewTLS(path, serviceName string) (credentials.TransportCredentials, error) + func Unmarshal(msg *pb.XuperMessage, message proto.Message) error + func VerifyChecksum(msg *pb.XuperMessage) bool + func VerifyMessageType(request *pb.XuperMessage, response *pb.XuperMessage, peerID string) bool + type Dispatcher interface + Dispatch func(*pb.XuperMessage, Stream) error + Register func(sub Subscriber) error + UnRegister func(sub Subscriber) error + func NewDispatcher(ctx *nctx.NetCtx) Dispatcher + type FilterStrategy string + type HandleFunc func(xctx.XContext, *pb.XuperMessage) (*pb.XuperMessage, error) + type MessageOption func(*pb.XuperMessage) + func WithBCName(bcname string) MessageOption + func WithErrorType(errorType pb.XuperMessage_ErrorType) MessageOption + func WithLogId(logid string) MessageOption + func WithVersion(version string) MessageOption + type Option struct + Accounts []string + Addresses []string + Filters []FilterStrategy + PeerIDs []string + Percent float32 + WhiteList map[string]bool + func Apply(optFunc []OptionFunc) *Option + type OptionFunc func(*Option) + func WithAccounts(accounts []string) OptionFunc + func WithAddresses(addresses []string) OptionFunc + func WithFilter(filters []FilterStrategy) OptionFunc + func WithPeerIDs(peerIDs []string) OptionFunc + func WithPercent(percent float32) OptionFunc + func WithWhiteList(whiteList map[string]bool) OptionFunc + type Server interface + Context func() *nctx.NetCtx + Init func(*nctx.NetCtx) error + NewSubscriber func(pb.XuperMessage_MessageType, interface{}, ...SubscriberOption) Subscriber + PeerInfo func() pb.PeerInfo + Register func(Subscriber) error + SendMessage func(xctx.XContext, *pb.XuperMessage, ...OptionFunc) error + SendMessageWithResponse func(xctx.XContext, *pb.XuperMessage, ...OptionFunc) ([]*pb.XuperMessage, error) + Start func() + Stop func() + UnRegister func(Subscriber) error + type Stream interface + Send func(*pb.XuperMessage) error + type Subscriber interface + GetMessageType func() pb.XuperMessage_MessageType + HandleMessage func(xctx.XContext, *pb.XuperMessage, Stream) error + Match func(*pb.XuperMessage) bool + func NewSubscriber(ctx *nctx.NetCtx, typ pb.XuperMessage_MessageType, v interface{}, ...) Subscriber + type SubscriberOption func(*subscriber) + func WithFilterBCName(bcName string) SubscriberOption + func WithFilterFrom(from string) SubscriberOption