import "github.com/topfreegames/pitaya"
app.go component.go group.go kick.go module.go pipeline.go push.go rpc.go timer.go
AddAcceptor adds a new acceptor to app
AddAcceptor向应用程序添加一个新的acceptor
func AddGRPCInfoToMetadata( metadata map[string]string, region string, host, port string, externalHost, externalPort string, ) map[string]string
AddGRPCInfoToMetadata adds host, external host and port into metadata AddGRPCInfoToMetadata将主机、外部主机和端口添加到元数据中
AddMetricTagsToPropagateCtx adds a key and metric tags that will be propagated through RPC calls. Use the same tags that are at 'pitaya.metrics.additionalTags' config AddMetricTagsToPropagateCtx将添加一个键和度量标记 通过RPC调用传播。使用与at相同的标记 “pitaya.metrics。additionalTags的配置
AddMetricsReporter to be used 使用AddMetricsReporter
func AddRoute( serverType string, routingFunction router.RoutingFunc, ) error
AddRoute adds a routing function to a server type AddRoute向服务器类型添加路由功能
AddToPropagateCtx adds a key and value that will be propagated through RPC calls AddToPropagateCtx添加将通过RPC调用传播的键和值
func AfterHandler(h pipeline.AfterHandlerTempl)
AfterHandler pushs a function to the back of the functions pipeline that will be executed after the handler method AfterHandler将函数推送到函数管道的后面 在处理程序方法之后执行
func BeforeHandler(h pipeline.HandlerTempl)
BeforeHandler pushs a function to the back of the functions pipeline that will be executed before the handler method BeforeHandler将函数推送到函数管道的后面 在处理程序方法之前执行
func Configure( isFrontend bool, serverType string, serverMode ServerMode, serverMetadata map[string]string, cfgs ...*viper.Viper, )
Configure configures the app Configure配置应用程序
Descriptor returns the protobuf message descriptor for a given message name 描述符返回给定消息名称的protobuf消息描述符
Documentation returns handler and remotes documentacion 文档返回处理程序和远程documentacion
Error creates a new error with a code, message and metadata 使用代码、消息和元数据创建新错误
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 从给定上下文检索opentracing span上下文 可以直接或通过RPC调用接收span上下文
GetConfig gets the pitaya config instance 获取火龙果配置实例
GetDefaultLoggerFromCtx returns the default logger from the given context GetDefaultLoggerFromCtx从给定的上下文返回默认的日志记录器
GetDieChan gets the channel that the app sinalizes when its going to die GetDieChan获得应用程序在它将死时进行中国化的通道
GetFromPropagateCtx adds a key and value that came through RPC calls GetFromPropagateCtx添加来自RPC调用的键和值
GetMetricsReporters gets registered metrics reporters GetMetricsReporters获得注册的度量记者
func GetModule(name string) (interfaces.Module, error)
GetModule gets a module with a name 获取具有名称的模块
func GetSerializer() serialize.Serializer
GetSerializer gets the app serializer 获取应用程序序列化器
GetServer gets the local server instance 获取本地服务器实例
GetServerByID returns the server with the specified id GetServerByID返回具有指定id的服务器
GetServerID returns the generated server id GetServerID返回生成的服务器id
GetServers get all servers 获取所有服务器
GetServersByType get all servers of type 获取所有类型的服务器
GetSessionFromCtx retrieves a session from a given context GetSessionFromCtx从给定上下文检索会话
GroupAddMember adds UID to group GroupAddMember将UID添加到组
func GroupBroadcast(ctx context.Context, frontendType, groupName, route string, v interface{}) error
GroupBroadcast pushes the message to all members inside group GroupBroadcast将消息推送给组内的所有成员
GroupContainsMember checks whether an UID is contained in group or not GroupContainsMember检查是否在组中包含UID
GroupCountMembers get current member amount in group GroupCountMembers获取当前组中的成员数量
GroupCreate creates a group 创建一个组
GroupCreateWithTTL creates a group with given TTL GroupCreateWithTTL使用给定的TTL创建一个组
GroupDelete deletes whole group, including UIDs and base group GroupDelete删除整个组,包括uid和基组
GroupMembers returns all member's UIDs GroupMembers返回所有成员的uid
GroupRemoveAll clears all UIDs GroupRemoveAll清除所有uid
GroupRemoveMember removes specified UID from group GroupRemoveMember从组中删除指定的UID
GroupRenewTTL renews group with the initial TTL GroupRenewTTL用初始TTL更新组
func InitGroups(groupService groups.GroupService)
InitGroups should be called once at the beginning of the application to setup the service type that will manage the groups 应该在应用程序开始时调用InitGroups一次,以设置将管理组的服务类型
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. NewAfterTimer返回一个新的计时器,其中包含一个将被调用的函数 在duration之后,由duration参数指定。 持续时间d必须大于零;如果没有,NewAfterTimer将陷入恐慌。 停止计时器以释放相关资源。
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. NewCondTimer返回一个新的Timer,其中包含一个将被调用的函数 当条件满足条件参数指定的条件时。 持续时间d必须大于零;如果没有,NewCondTimer将陷入恐慌。 停止计时器以释放相关资源。
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. NewCountTimer返回一个新的Timer,其中包含一个将被调用的函数 由duration参数指定的期间。计数次数后,定时器 将自动停止,它调整的间隔慢的接收器。 持续时间d必须大于零;如果没有,NewCountTimer将陷入恐慌。 停止计时器以释放相关资源。
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. NewTimer返回一个新的Timer,其中包含一个将被调用的函数 由duration参数指定的期间。它调整时间间隔 缓慢的接收器。 持续时间d必须大于零;如果没有,NewTimer将会恐慌。 停止计时器以释放相关资源。
RPC calls a method in a different server RPC调用不同服务器中的方法
func RPCTo(ctx context.Context, serverID, routeStr string, reply proto.Message, arg proto.Message) error
RPCTo send a rpc to a specific server 将rpc发送到特定的服务器
Register register a component with options 用选项注册一个组件
func RegisterModule(module interfaces.Module, name string) error
RegisterModule registers a module, by default it register after registered modules RegisterModule注册一个模块,默认情况下,它在注册模块之后注册
func RegisterModuleAfter(module interfaces.Module, name string) error
RegisterModuleAfter registers a module after all registered modules RegisterModuleAfter在所有已注册的模块之后注册一个模块
func RegisterModuleBefore(module interfaces.Module, name string) error
RegisterModuleBefore registers a module before all registered modules RegisterModuleBefore在所有注册的模块之前注册一个模块
RegisterRPCJob registers rpc job to execute jobs with retries RegisterRPCJob注册rpc作业来执行带有重试的作业
RegisterRemote register a remote component with options 注册一个带有选项的远程组件
func ReliableRPC( routeStr string, metadata map[string]interface{}, reply, arg proto.Message, ) (jid string, err error)
ReliableRPC enqueues RPC to worker so it's executed asynchronously Default enqueue options are used ReliableRPC将RPC排队到worker,因此它是异步执行的 使用默认的排队选项
func ReliableRPCWithOptions( routeStr string, metadata map[string]interface{}, reply, arg proto.Message, opts *worker.EnqueueOpts, ) (jid string, err error)
ReliableRPCWithOptions enqueues RPC to worker Receive worker options for this specific RPC ReliableRPCWithOptions将RPC排队到工作进程 接收此特定RPC的工作程序选项
SendKickToUsers sends kick to an user array SendKickToUsers向用户数组发送kick
func SendPushToUsers(route string, v interface{}, uids []string, frontendType string) ([]string, error)
SendPushToUsers sends a message to the given list of users SendPushToUsers向给定的用户列表发送消息
SetDebug toggles debug on/off SetDebug开关调试开关
SetDictionary sets routes map SetDictionary设置路由映射
SetHeartbeatTime sets the heartbeat time 设置心跳时间
SetLogger logger setter
func SetPacketDecoder(d codec.PacketDecoder)
SetPacketDecoder更改用于解析接收到的消息的解码器
func SetPacketEncoder(e codec.PacketEncoder)
SetPacketEncoder changes the encoder used to package outgoing messages SetPacketEncoder改变了用于打包输出消息的编码器
SetRPCClient to be used 使用setrlient
SetRPCServer to be used 使用SetRPCServer
func SetSerializer(seri serialize.Serializer)
SetSerializer customize application serializer, which automatically Marshal and UnMarshal handler payload SetSerializer自定义应用程序序列化器,它会自动封送 以及解封处理程序负载
func SetServiceDiscoveryClient(s cluster.ServiceDiscovery)
SetServiceDiscoveryClient to be used 要使用的SetServiceDiscoveryClient
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. SetTimerBacklog设置计时器创建/关闭通道backlog,一个小的backlog 当调用NewTimer/NewCountTimer/timer.Stop时,可能会导致逻辑被阻塞 在主逻辑中。
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 设定自动抄表机的精度,和时间精度不能差 超过1毫秒,并且在应用程序运行后不能更改。默认的 精度time.Second
func Shutdown()
Shutdown send a signal to let 'pitaya' shutdown itself. 关机发送一个信号让火龙果自己关机。
func Start()
Start starts the app 启动应用程序
StartWorker configures, starts and returns pitaya worker StartWorker配置、启动和返回火龙果工作程序
type App struct {
// contains filtered or unexported fields
}
App is the base app struct App是基础的App结构体
ServerMode represents a server mode ServerMode表示服务器模式
const ( // Cluster represents a server running with connection to other servers Cluster ServerMode // Standalone represents a server running without connection to other servers Standalone )
Package pitaya imports 43 packages (graph) and is imported by 24 packages. Updated 26 days ago. Refresh now. Tools for package owners.