Documentation ¶
Index ¶
- Variables
- func AddRemoteService(ses cellnet.Session, svcid, name string)
- func ConnectDiscovery()
- func DiscoveryService(tgtSvcName string, opt DiscoveryOption, ...) cellnet.Peer
- func GetCommtype() string
- func GetDiscoveryAddr() string
- func GetLocalSvcID() string
- func GetPassThrough(ev cellnet.Event, ptrList ...interface{}) error
- func GetProcName() string
- func GetRemoteService(svcid string) cellnet.Session
- func GetSvcGroup() string
- func GetSvcIndex() string
- func GetWANIP() string
- func Init(name string)
- func InitServerConfig(serviceConf map[string]string)
- func LogParameter()
- func MakeLocalSvcID(svcName string) string
- func MakeSvcID(svcName string, svcIndex int, svcGroup string) string
- func ParseSvcID(svcid string) (svcName string, svcIndex int, svcGroup string, err error)
- func QueryService(svcName string, filterList ...FilterFunc) (ret interface{})
- func QueryServiceEx(svcName string, opt QueryServiceOption, filterList ...FilterFunc) (ret interface{})
- func Register(p cellnet.Peer, options ...interface{}) *discovery.ServiceDesc
- func RemoveRemoteService(ses cellnet.Session)
- func Reply(ev cellnet.Event, msg interface{})
- func SetRemoteServiceNotify(mode string, callback NotifyFunc)
- func Unregister(p cellnet.Peer)
- func VisitRemoteService(callback func(ses cellnet.Session, ctx *RemoteServiceContext) bool)
- func WaitExitSignal()
- type DiscoveryOption
- type FilterFunc
- type MatchRule
- type MultiPeer
- type NotifyFunc
- type QueryResult
- type QueryServiceOp
- type QueryServiceOption
- type RemoteServiceContext
- type ServiceIdentifyACK
- type ServiceMeta
- type SvcEventHooker
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidRelayMessage = errors.New("invalid relay message") ErrInvalidRelayPassthroughType = errors.New("invalid relay passthrough type") )
View Source
var (
LinkRules []MatchRule // 互联发现规则
)
Functions ¶
func AddRemoteService ¶
func DiscoveryService ¶
func DiscoveryService(tgtSvcName string, opt DiscoveryOption, peerCreator func(MultiPeer, *discovery.ServiceDesc)) cellnet.Peer
发现一个服务,服务可能拥有多个地址,每个地址返回时,创建一个connector并开启 DiscoveryService返回值返回持有多个Peer的peer, 判断Peer的IsReady可以得到所有连接准备好的状态
func GetCommtype ¶ added in v1.0.7
func GetCommtype() string
func GetDiscoveryAddr ¶
func GetDiscoveryAddr() string
func GetPassThrough ¶
获取Event中relay的透传数据
func GetSvcGroup ¶
func GetSvcGroup() string
func GetSvcIndex ¶
func GetSvcIndex() string
func InitServerConfig ¶ added in v1.0.8
func LogParameter ¶
func LogParameter()
func ParseSvcID ¶
func QueryService ¶
func QueryService(svcName string, filterList ...FilterFunc) (ret interface{})
根据给定的查询服务名,将结果经过各种过滤器处理后输出
func QueryServiceEx ¶
func QueryServiceEx(svcName string, opt QueryServiceOption, filterList ...FilterFunc) (ret interface{})
func Register ¶
func Register(p cellnet.Peer, options ...interface{}) *discovery.ServiceDesc
将Acceptor注册到服务发现,IP自动取本地IP
func RemoveRemoteService ¶
func VisitRemoteService ¶
func VisitRemoteService(callback func(ses cellnet.Session, ctx *RemoteServiceContext) bool)
遍历远程服务(已经连接到本进程)
func WaitExitSignal ¶
func WaitExitSignal()
Types ¶
type DiscoveryOption ¶
type FilterFunc ¶
type FilterFunc func(*discovery.ServiceDesc) interface{}
返回值含义: 1. true等效于QueryServiceOp_NextFilter,转到下一个内层循环 2. false等效于QueryServiceOp_NextDesc, 转到下一个外层循环 3. QueryServiceOp_End: 终止所有遍历循环 4. Filter中将类型转为QueryResult,则在QueryService函数返回
func Filter_MatchSvcGroup ¶
func Filter_MatchSvcGroup(svcGroup string) FilterFunc
匹配指定的服务组,服务组空时,匹配所有
type MultiPeer ¶
type MultiPeer interface { GetPeers() []cellnet.Peer cellnet.ContextSet AddPeer(sd *discovery.ServiceDesc, p cellnet.Peer) }
一类服务发起多个连接(不是同一地址), 比如 login1 login2
type NotifyFunc ¶
type NotifyFunc func(ctx *RemoteServiceContext, ses cellnet.Session)
type QueryResult ¶
type QueryResult interface{}
type QueryServiceOp ¶
type QueryServiceOp int
const ( QueryServiceOp_NextFilter QueryServiceOp = iota QueryServiceOp_NextDesc QueryServiceOp_End )
type QueryServiceOption ¶
type QueryServiceOption struct {
Sort bool
}
type RemoteServiceContext ¶
func SessionToContext ¶
func SessionToContext(ses cellnet.Session) *RemoteServiceContext
取得其他服务器的会话对应的上下文
type ServiceIdentifyACK ¶
func (*ServiceIdentifyACK) String ¶
func (self *ServiceIdentifyACK) String() string
type ServiceMeta ¶
type SvcEventHooker ¶
type SvcEventHooker struct { }
服务互联消息处理
func (SvcEventHooker) OnInboundEvent ¶
func (SvcEventHooker) OnInboundEvent(inputEvent cellnet.Event) (outputEvent cellnet.Event)
func (SvcEventHooker) OnOutboundEvent ¶
func (SvcEventHooker) OnOutboundEvent(inputEvent cellnet.Event) (outputEvent cellnet.Event)
Click to show internal directories.
Click to hide internal directories.