Documentation ¶
Index ¶
- func AddAcceptor(ac acceptor.Acceptor)
- func AddMetricsReporter(mr metrics.Reporter)
- func AddRoute(serverType string, routingFunction router.RoutingFunc) error
- func AddToPropagateCtx(ctx context.Context, key string, val interface{}) context.Context
- func AfterHandler(h pipeline.Handler)
- func BeforeHandler(h pipeline.Handler)
- func Configure(isFrontend bool, serverType string, serverMode ServerMode, ...)
- func Error(err error, code string, metadata ...map[string]string) *errors.Error
- func ExtractSpan(ctx context.Context) (opentracing.SpanContext, error)
- func GetConfig() *config.Config
- func GetDieChan() chan bool
- func GetFromPropagateCtx(ctx context.Context, key string) interface{}
- func GetMetricsReporters() []metrics.Reporter
- func GetModule(name string) (interfaces.Module, error)
- func GetSerializer() serialize.Serializer
- func GetServer() *cluster.Server
- func GetServerByID(id string) (*cluster.Server, error)
- func GetServerID() string
- func GetServersByType(t string) (map[string]*cluster.Server, error)
- func GetSessionFromCtx(ctx context.Context) *session.Session
- func NewAfterTimer(duration time.Duration, fn timer.Func) *timer.Timer
- func NewCondTimer(condition timer.Condition, fn timer.Func) (*timer.Timer, error)
- func NewCountTimer(interval time.Duration, count int, fn timer.Func) *timer.Timer
- func NewTimer(interval time.Duration, fn timer.Func) *timer.Timer
- func RPC(ctx context.Context, routeStr string, reply proto.Message, arg proto.Message) error
- func RPCTo(ctx context.Context, serverID, routeStr string, reply proto.Message, ...) error
- func Register(c component.Component, options ...component.Option)
- func RegisterModule(module interfaces.Module, name string) error
- func RegisterRemote(c component.Component, options ...component.Option)
- func SendPushToUsers(route string, v interface{}, uids []string, frontendType string) error
- func SetDebug(debug bool)
- func SetDictionary(dict map[string]uint16) error
- func SetHeartbeatTime(interval time.Duration)
- func SetLogger(l logger.Logger)
- func SetPacketDecoder(d codec.PacketDecoder)
- func SetPacketEncoder(e codec.PacketEncoder)
- func SetRPCClient(s cluster.RPCClient)
- func SetRPCServer(s cluster.RPCServer)
- func SetSerializer(seri serialize.Serializer)
- func SetServiceDiscoveryClient(s cluster.ServiceDiscovery)
- func SetTimerBacklog(c int)
- func SetTimerPrecision(precision time.Duration)
- func Shutdown()
- func Start()
- type App
- type Group
- func (c *Group) Add(session *session.Session) error
- func (c *Group) Broadcast(route string, v interface{}) error
- func (c *Group) Close() error
- func (c *Group) Contains(uid string) bool
- func (c *Group) Count() int
- func (c *Group) Leave(s *session.Session) error
- func (c *Group) LeaveAll() error
- func (c *Group) Member(uid string) (*session.Session, error)
- func (c *Group) Members() []string
- func (c *Group) Multicast(route string, v interface{}, filter SessionFilter) error
- type ServerMode
- type SessionFilter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddMetricsReporter ¶
AddMetricsReporter to be used
func AddRoute ¶
func AddRoute( serverType string, routingFunction router.RoutingFunc, ) error
AddRoute adds a routing function to a server type
func AddToPropagateCtx ¶
AddToPropagateCtx adds a key and value that will be propagated through RPC calls
func AfterHandler ¶
AfterHandler pushs a function to the back of the functions pipeline that will be executed after the handler method
func BeforeHandler ¶
BeforeHandler pushs a function to the back of the functions pipeline that will be executed before the handler method
func Configure ¶
func Configure( isFrontend bool, serverType string, serverMode ServerMode, serverMetadata map[string]string, cfgs ...*viper.Viper, )
Configure configures the app
func ExtractSpan ¶
func ExtractSpan(ctx context.Context) (opentracing.SpanContext, error)
ExtractSpan retrieves an opentracing span context from the given context The span context can be received directly or via an RPC call
func GetDieChan ¶
func GetDieChan() chan bool
GetDieChan gets the channel that the app sinalizes when its going to die
func GetFromPropagateCtx ¶
GetFromPropagateCtx adds a key and value that came through RPC calls
func GetMetricsReporters ¶
GetMetricsReporters gets registered metrics reporters
func GetModule ¶
func GetModule(name string) (interfaces.Module, error)
GetModule gets a module with a name
func GetSerializer ¶
func GetSerializer() serialize.Serializer
GetSerializer gets the app serializer
func GetServerByID ¶
GetServerByID returns the server with the specified id
func GetServersByType ¶
GetServersByType get all servers of type
func GetSessionFromCtx ¶
GetSessionFromCtx retrieves a session from a given context
func NewAfterTimer ¶
NewAfterTimer returns a new Timer containing a function that will be called after duration that specified by the duration argument. The duration d must be greater than zero; if not, NewAfterTimer will panic. Stop the timer to release associated resources.
func NewCondTimer ¶
NewCondTimer returns a new Timer containing a function that will be called when condition satisfied that specified by the condition argument. The duration d must be greater than zero; if not, NewCondTimer will panic. Stop the timer to release associated resources.
func NewCountTimer ¶
NewCountTimer returns a new Timer containing a function that will be called with a period specified by the duration argument. After count times, timer will be stopped automatically, It adjusts the intervals for slow receivers. The duration d must be greater than zero; if not, NewCountTimer will panic. Stop the timer to release associated resources.
func NewTimer ¶
NewTimer returns a new Timer containing a function that will be called with a period specified by the duration argument. It adjusts the intervals for slow receivers. The duration d must be greater than zero; if not, NewTimer will panic. Stop the timer to release associated resources.
func RPCTo ¶
func RPCTo(ctx context.Context, serverID, routeStr string, reply proto.Message, arg proto.Message) error
RPCTo send a rpc to a specific server
func RegisterModule ¶
func RegisterModule(module interfaces.Module, name string) error
RegisterModule registers a module
func RegisterRemote ¶
RegisterRemote register a remote component with options
func SendPushToUsers ¶
SendPushToUsers sends a message to the given list of users
func SetHeartbeatTime ¶
SetHeartbeatTime sets the heartbeat time
func SetPacketDecoder ¶
func SetPacketDecoder(d codec.PacketDecoder)
SetPacketDecoder changes the decoder used to parse messages received
func SetPacketEncoder ¶
func SetPacketEncoder(e codec.PacketEncoder)
SetPacketEncoder changes the encoder used to package outgoing messages
func SetSerializer ¶
func SetSerializer(seri serialize.Serializer)
SetSerializer customize application serializer, which automatically Marshal and UnMarshal handler payload
func SetServiceDiscoveryClient ¶
func SetServiceDiscoveryClient(s cluster.ServiceDiscovery)
SetServiceDiscoveryClient to be used
func SetTimerBacklog ¶
func SetTimerBacklog(c int)
SetTimerBacklog set the timer created/closing channel backlog, A small backlog may cause the logic to be blocked when call NewTimer/NewCountTimer/timer.Stop in main logic gorontine.
func SetTimerPrecision ¶
SetTimerPrecision set the ticker precision, and time precision can not less than a Millisecond, and can not change after application running. The default precision is time.Second
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group represents a session group which is used to manage a number of sessions, data sent to the group will be sent to all sessions in it.
type ServerMode ¶
type ServerMode byte
ServerMode represents a server mode
const ( // Cluster represents a server running with connection to other servers Cluster ServerMode // Standalone represents a server running without connection to other servers Standalone )
type SessionFilter ¶
SessionFilter represents a filter which is used to filter sessions when Multicast, the session will receive the message when the filter returns true.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
examples
|
|
demo/cluster_protobuf/protos
Package protos is a generated protocol buffer package.
|
Package protos is a generated protocol buffer package. |
demo/protos
Package protos is a generated protocol buffer package.
|
Package protos is a generated protocol buffer package. |
testing/protos
Package protos is a generated protocol buffer package.
|
Package protos is a generated protocol buffer package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
internal
|
|
codec/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
message/mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |