Documentation ¶
Index ¶
- func GetBindBroadcastTopic(svType string) string
- func GetUserKickTopic(uid string, svType string) string
- func GetUserMessagesTopic(uid string, svType string) string
- type Action
- type ConfigInfoRetriever
- type GRPCClient
- func (gs *GRPCClient) AddServer(sv *Server)
- func (gs *GRPCClient) AfterInit()
- func (gs *GRPCClient) BeforeShutdown()
- func (gs *GRPCClient) BroadcastSessionBind(uid string) error
- func (gs *GRPCClient) Call(ctx context.Context, rpcType protos.RPCType, route *route.Route, ...) (*protos.Response, error)
- func (gs *GRPCClient) Call2(ctx context.Context, routeKey string, req interface{}, resp interface{}, ...) error
- func (gs *GRPCClient) Init() error
- func (gs *GRPCClient) RemoveServer(sv *Server)
- func (gs *GRPCClient) Send(uid string, d []byte) error
- func (gs *GRPCClient) SendKick(userID string, serverType string, kick *protos.KickMsg) error
- func (gs *GRPCClient) SendPush(userID string, frontendSv *Server, push *protos.Push) error
- func (gs *GRPCClient) Shutdown() error
- type GRPCServer
- type InfoRetriever
- type NatsRPCClient
- func (ns *NatsRPCClient) AfterInit()
- func (ns *NatsRPCClient) BeforeShutdown()
- func (ns *NatsRPCClient) BroadcastSessionBind(uid string) error
- func (ns *NatsRPCClient) Call(ctx context.Context, rpcType protos.RPCType, route *route.Route, ...) (*protos.Response, error)
- func (ns *NatsRPCClient) Init() error
- func (ns *NatsRPCClient) Send(topic string, data []byte) error
- func (ns *NatsRPCClient) SendKick(userID string, serverType string, kick *protos.KickMsg) error
- func (ns *NatsRPCClient) SendPush(userID string, frontendSv *Server, push *protos.Push) error
- func (ns *NatsRPCClient) Shutdown() error
- type NatsRPCServer
- func (ns *NatsRPCServer) AfterInit()
- func (ns *NatsRPCServer) BeforeShutdown()
- func (ns *NatsRPCServer) GetBindingsChannel() chan *nats.Msg
- func (ns *NatsRPCServer) GetUnhandledRequestsChannel() chan *protos.Request
- func (ns *NatsRPCServer) Init() error
- func (ns *NatsRPCServer) SetPitayaServer(ps protos.PitayaServer)
- func (ns *NatsRPCServer) Shutdown() error
- type RPCClient
- type RPCServer
- type RemoteBindingListener
- type SDListener
- type Server
- type ServiceDiscovery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetBindBroadcastTopic ¶
GetBindBroadcastTopic gets the topic on which bind events will be broadcasted
func GetUserKickTopic ¶ added in v0.7.6
GetUserKickTopic get the topic for kicking an user
func GetUserMessagesTopic ¶
GetUserMessagesTopic get the topic for user
Types ¶
type ConfigInfoRetriever ¶ added in v0.7.6
type ConfigInfoRetriever struct {
// contains filtered or unexported fields
}
ConfigInfoRetriever gets cluster info from config Implements InfoRetriever interface
func NewConfigInfoRetriever ¶ added in v0.7.6
func NewConfigInfoRetriever(c *config.Config) *ConfigInfoRetriever
NewConfigInfoRetriever returns a *ConfigInfoRetriever
func (*ConfigInfoRetriever) Region ¶ added in v0.7.6
func (c *ConfigInfoRetriever) Region() string
Region gets server's region from config
type GRPCClient ¶
type GRPCClient struct {
// contains filtered or unexported fields
}
GRPCClient rpc server struct
func NewGRPCClient ¶
func NewGRPCClient( config *config.Config, server *Server, metricsReporters []metrics.Reporter, bindingStorage interfaces.BindingStorage, infoRetriever InfoRetriever, ) (*GRPCClient, error)
NewGRPCClient returns a new instance of GRPCClient
func (*GRPCClient) AddServer ¶
func (gs *GRPCClient) AddServer(sv *Server)
AddServer is called when a new server is discovered
func (*GRPCClient) AfterInit ¶
func (gs *GRPCClient) AfterInit()
AfterInit runs after initialization
func (*GRPCClient) BeforeShutdown ¶
func (gs *GRPCClient) BeforeShutdown()
BeforeShutdown runs before shutdown
func (*GRPCClient) BroadcastSessionBind ¶
func (gs *GRPCClient) BroadcastSessionBind(uid string) error
BroadcastSessionBind sends the binding information to other servers that may be interested in this info
func (*GRPCClient) Call ¶
func (gs *GRPCClient) Call( ctx context.Context, rpcType protos.RPCType, route *route.Route, session *session.Session, msg *message.Message, server *Server, ) (*protos.Response, error)
Call makes a RPC Call
func (*GRPCClient) RemoveServer ¶
func (gs *GRPCClient) RemoveServer(sv *Server)
RemoveServer is called when a server is removed
func (*GRPCClient) Send ¶
func (gs *GRPCClient) Send(uid string, d []byte) error
Send not implemented in grpc client
type GRPCServer ¶
type GRPCServer struct {
// contains filtered or unexported fields
}
GRPCServer rpc server struct
func NewGRPCServer ¶
func NewGRPCServer(config *config.Config, server *Server, metricsReporters []metrics.Reporter) (*GRPCServer, error)
NewGRPCServer constructor
func (*GRPCServer) AfterInit ¶
func (gs *GRPCServer) AfterInit()
AfterInit runs after initialization
func (*GRPCServer) BeforeShutdown ¶
func (gs *GRPCServer) BeforeShutdown()
BeforeShutdown runs before shutdown
func (*GRPCServer) SetPitayaServer ¶
func (gs *GRPCServer) SetPitayaServer(ps protos.PitayaServer)
SetPitayaServer sets the pitaya server
type InfoRetriever ¶ added in v0.7.6
type InfoRetriever interface {
Region() string
}
InfoRetriever gets cluster info It can be implemented, for exemple, by reading env var, config or by accessing the cluster API
type NatsRPCClient ¶
type NatsRPCClient struct {
// contains filtered or unexported fields
}
NatsRPCClient struct
func NewNatsRPCClient ¶
func NewNatsRPCClient( config *config.Config, server *Server, metricsReporters []metrics.Reporter, appDieChan chan bool, ) (*NatsRPCClient, error)
NewNatsRPCClient ctor
func (*NatsRPCClient) AfterInit ¶
func (ns *NatsRPCClient) AfterInit()
AfterInit runs after initialization
func (*NatsRPCClient) BeforeShutdown ¶
func (ns *NatsRPCClient) BeforeShutdown()
BeforeShutdown runs before shutdown
func (*NatsRPCClient) BroadcastSessionBind ¶
func (ns *NatsRPCClient) BroadcastSessionBind(uid string) error
BroadcastSessionBind sends the binding information to other servers that may br interested in this info
func (*NatsRPCClient) Call ¶
func (ns *NatsRPCClient) Call( ctx context.Context, rpcType protos.RPCType, route *route.Route, session *session.Session, msg *message.Message, server *Server, ) (*protos.Response, error)
Call calls a method remotelly
func (*NatsRPCClient) Send ¶
func (ns *NatsRPCClient) Send(topic string, data []byte) error
Send publishes a message in a given topic
func (*NatsRPCClient) Shutdown ¶
func (ns *NatsRPCClient) Shutdown() error
Shutdown stops nats rpc server
type NatsRPCServer ¶
type NatsRPCServer struct {
// contains filtered or unexported fields
}
NatsRPCServer struct
func NewNatsRPCServer ¶
func NewNatsRPCServer( config *config.Config, server *Server, metricsReporters []metrics.Reporter, appDieChan chan bool, ) (*NatsRPCServer, error)
NewNatsRPCServer ctor
func (*NatsRPCServer) AfterInit ¶
func (ns *NatsRPCServer) AfterInit()
AfterInit runs after initialization
func (*NatsRPCServer) BeforeShutdown ¶
func (ns *NatsRPCServer) BeforeShutdown()
BeforeShutdown runs before shutdown
func (*NatsRPCServer) GetBindingsChannel ¶
func (ns *NatsRPCServer) GetBindingsChannel() chan *nats.Msg
GetBindingsChannel gets the channel that will receive all bindings
func (*NatsRPCServer) GetUnhandledRequestsChannel ¶
func (ns *NatsRPCServer) GetUnhandledRequestsChannel() chan *protos.Request
GetUnhandledRequestsChannel gets the unhandled requests channel from nats rpc server
func (*NatsRPCServer) SetPitayaServer ¶
func (ns *NatsRPCServer) SetPitayaServer(ps protos.PitayaServer)
SetPitayaServer sets the pitaya server
func (*NatsRPCServer) Shutdown ¶
func (ns *NatsRPCServer) Shutdown() error
Shutdown stops nats rpc server
type RPCClient ¶
type RPCClient interface { Send(route string, data []byte) error SendPush(userID string, frontendSv *Server, push *protos.Push) error SendKick(userID string, serverType string, kick *protos.KickMsg) error BroadcastSessionBind(uid string) error Call(ctx context.Context, rpcType protos.RPCType, route *route.Route, session *session.Session, msg *message.Message, server *Server) (*protos.Response, error) interfaces.Module }
RPCClient interface
type RPCServer ¶
type RPCServer interface { SetPitayaServer(protos.PitayaServer) interfaces.Module }
RPCServer interface
type RemoteBindingListener ¶
type RemoteBindingListener interface {
OnUserBind(uid, fid string)
}
RemoteBindingListener listens to session bindings in remote servers
type SDListener ¶
SDListener interface
type Server ¶
type Server struct { ID string `json:"id"` Type string `json:"type"` Metadata map[string]string `json:"metadata"` Frontend bool `json:"frontend"` Hostname string `json:"hostname"` }
Server struct
func (*Server) AsJSONString ¶
AsJSONString returns the server as a json string
type ServiceDiscovery ¶
type ServiceDiscovery interface { GetServersByType(serverType string) (map[string]*Server, error) GetServer(id string) (*Server, error) GetServers() []*Server SyncServers() error AddListener(listener SDListener) interfaces.Module }
ServiceDiscovery is the interface for a service discovery client
func NewEtcdServiceDiscovery ¶
func NewEtcdServiceDiscovery( config *config.Config, server *Server, appDieChan chan bool, cli ...*clientv3.Client, ) (ServiceDiscovery, error)
NewEtcdServiceDiscovery ctor