pitaya: github.com/topfreegames/pitaya Index | Files | Directories

package pitaya

import "github.com/topfreegames/pitaya"

Index

Package Files

app.go component.go group.go kick.go module.go pipeline.go push.go rpc.go timer.go

func AddAcceptor Uses

func AddAcceptor(ac acceptor.Acceptor)

AddAcceptor adds a new acceptor to app
AddAcceptor向应用程序添加一个新的acceptor

func AddGRPCInfoToMetadata Uses

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将主机、外部主机和端口添加到元数据中

func AddMetricTagsToPropagateCtx Uses

func AddMetricTagsToPropagateCtx(
    ctx context.Context,
    tags map[string]string,
) context.Context

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的配置

func AddMetricsReporter Uses

func AddMetricsReporter(mr metrics.Reporter)

AddMetricsReporter to be used 使用AddMetricsReporter

func AddRoute Uses

func AddRoute(
    serverType string,
    routingFunction router.RoutingFunc,
) error

AddRoute adds a routing function to a server type AddRoute向服务器类型添加路由功能

func AddToPropagateCtx Uses

func AddToPropagateCtx(ctx context.Context, key string, val interface{}) context.Context

AddToPropagateCtx adds a key and value that will be propagated through RPC calls AddToPropagateCtx添加将通过RPC调用传播的键和值

func AfterHandler Uses

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 Uses

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 Uses

func Configure(
    isFrontend bool,
    serverType string,
    serverMode ServerMode,
    serverMetadata map[string]string,
    cfgs ...*viper.Viper,
)

Configure configures the app Configure配置应用程序

func Descriptor Uses

func Descriptor(protoName string) ([]byte, error)

Descriptor returns the protobuf message descriptor for a given message name 描述符返回给定消息名称的protobuf消息描述符

func Documentation Uses

func Documentation(getPtrNames bool) (map[string]interface{}, error)

Documentation returns handler and remotes documentacion 文档返回处理程序和远程documentacion

func Error Uses

func Error(err error, code string, metadata ...map[string]string) *errors.Error

Error creates a new error with a code, message and metadata 使用代码、消息和元数据创建新错误

func ExtractSpan Uses

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上下文

func GetConfig Uses

func GetConfig() *config.Config

GetConfig gets the pitaya config instance 获取火龙果配置实例

func GetDefaultLoggerFromCtx Uses

func GetDefaultLoggerFromCtx(ctx context.Context) logger.Logger

GetDefaultLoggerFromCtx returns the default logger from the given context GetDefaultLoggerFromCtx从给定的上下文返回默认的日志记录器

func GetDieChan Uses

func GetDieChan() chan bool

GetDieChan gets the channel that the app sinalizes when its going to die GetDieChan获得应用程序在它将死时进行中国化的通道

func GetFromPropagateCtx Uses

func GetFromPropagateCtx(ctx context.Context, key string) interface{}

GetFromPropagateCtx adds a key and value that came through RPC calls GetFromPropagateCtx添加来自RPC调用的键和值

func GetMetricsReporters Uses

func GetMetricsReporters() []metrics.Reporter

GetMetricsReporters gets registered metrics reporters GetMetricsReporters获得注册的度量记者

func GetModule Uses

func GetModule(name string) (interfaces.Module, error)

GetModule gets a module with a name 获取具有名称的模块

func GetSerializer Uses

func GetSerializer() serialize.Serializer

GetSerializer gets the app serializer 获取应用程序序列化器

func GetServer Uses

func GetServer() *cluster.Server

GetServer gets the local server instance 获取本地服务器实例

func GetServerByID Uses

func GetServerByID(id string) (*cluster.Server, error)

GetServerByID returns the server with the specified id GetServerByID返回具有指定id的服务器

func GetServerID Uses

func GetServerID() string

GetServerID returns the generated server id GetServerID返回生成的服务器id

func GetServers Uses

func GetServers() []*cluster.Server

GetServers get all servers 获取所有服务器

func GetServersByType Uses

func GetServersByType(t string) (map[string]*cluster.Server, error)

GetServersByType get all servers of type 获取所有类型的服务器

func GetSessionFromCtx Uses

func GetSessionFromCtx(ctx context.Context) *session.Session

GetSessionFromCtx retrieves a session from a given context GetSessionFromCtx从给定上下文检索会话

func GroupAddMember Uses

func GroupAddMember(ctx context.Context, groupName, uid string) error

GroupAddMember adds UID to group GroupAddMember将UID添加到组

func GroupBroadcast Uses

func GroupBroadcast(ctx context.Context, frontendType, groupName, route string, v interface{}) error

GroupBroadcast pushes the message to all members inside group GroupBroadcast将消息推送给组内的所有成员

func GroupContainsMember Uses

func GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error)

GroupContainsMember checks whether an UID is contained in group or not GroupContainsMember检查是否在组中包含UID

func GroupCountMembers Uses

func GroupCountMembers(ctx context.Context, groupName string) (int, error)

GroupCountMembers get current member amount in group GroupCountMembers获取当前组中的成员数量

func GroupCreate Uses

func GroupCreate(ctx context.Context, groupName string) error

GroupCreate creates a group 创建一个组

func GroupCreateWithTTL Uses

func GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error

GroupCreateWithTTL creates a group with given TTL GroupCreateWithTTL使用给定的TTL创建一个组

func GroupDelete Uses

func GroupDelete(ctx context.Context, groupName string) error

GroupDelete deletes whole group, including UIDs and base group GroupDelete删除整个组,包括uid和基组

func GroupMembers Uses

func GroupMembers(ctx context.Context, groupName string) ([]string, error)

GroupMembers returns all member's UIDs GroupMembers返回所有成员的uid

func GroupRemoveAll Uses

func GroupRemoveAll(ctx context.Context, groupName string) error

GroupRemoveAll clears all UIDs GroupRemoveAll清除所有uid

func GroupRemoveMember Uses

func GroupRemoveMember(ctx context.Context, groupName, uid string) error

GroupRemoveMember removes specified UID from group GroupRemoveMember从组中删除指定的UID

func GroupRenewTTL Uses

func GroupRenewTTL(ctx context.Context, groupName string) error

GroupRenewTTL renews group with the initial TTL GroupRenewTTL用初始TTL更新组

func InitGroups Uses

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一次,以设置将管理组的服务类型

func NewAfterTimer Uses

func NewAfterTimer(duration time.Duration, fn timer.Func) *timer.Timer

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将陷入恐慌。 停止计时器以释放相关资源。

func NewCondTimer Uses

func NewCondTimer(condition timer.Condition, fn timer.Func) (*timer.Timer, error)

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将陷入恐慌。 停止计时器以释放相关资源。

func NewCountTimer Uses

func NewCountTimer(interval time.Duration, count int, fn timer.Func) *timer.Timer

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将陷入恐慌。 停止计时器以释放相关资源。

func NewTimer Uses

func NewTimer(interval time.Duration, fn timer.Func) *timer.Timer

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将会恐慌。 停止计时器以释放相关资源。

func RPC Uses

func RPC(ctx context.Context, routeStr string, reply proto.Message, arg proto.Message) error

RPC calls a method in a different server RPC调用不同服务器中的方法

func RPCTo Uses

func RPCTo(ctx context.Context, serverID, routeStr string, reply proto.Message, arg proto.Message) error

RPCTo send a rpc to a specific server 将rpc发送到特定的服务器

func Register Uses

func Register(c component.Component, options ...component.Option)

Register register a component with options 用选项注册一个组件

func RegisterModule Uses

func RegisterModule(module interfaces.Module, name string) error

RegisterModule registers a module, by default it register after registered modules RegisterModule注册一个模块,默认情况下,它在注册模块之后注册

func RegisterModuleAfter Uses

func RegisterModuleAfter(module interfaces.Module, name string) error

RegisterModuleAfter registers a module after all registered modules RegisterModuleAfter在所有已注册的模块之后注册一个模块

func RegisterModuleBefore Uses

func RegisterModuleBefore(module interfaces.Module, name string) error

RegisterModuleBefore registers a module before all registered modules RegisterModuleBefore在所有注册的模块之前注册一个模块

func RegisterRPCJob Uses

func RegisterRPCJob(rpcJob worker.RPCJob) error

RegisterRPCJob registers rpc job to execute jobs with retries RegisterRPCJob注册rpc作业来执行带有重试的作业

func RegisterRemote Uses

func RegisterRemote(c component.Component, options ...component.Option)

RegisterRemote register a remote component with options 注册一个带有选项的远程组件

func ReliableRPC Uses

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 Uses

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的工作程序选项

func SendKickToUsers Uses

func SendKickToUsers(uids []string, frontendType string) ([]string, error)

SendKickToUsers sends kick to an user array SendKickToUsers向用户数组发送kick

func SendPushToUsers Uses

func SendPushToUsers(route string, v interface{}, uids []string, frontendType string) ([]string, error)

SendPushToUsers sends a message to the given list of users SendPushToUsers向给定的用户列表发送消息

func SetDebug Uses

func SetDebug(debug bool)

SetDebug toggles debug on/off SetDebug开关调试开关

func SetDictionary Uses

func SetDictionary(dict map[string]uint16) error

SetDictionary sets routes map SetDictionary设置路由映射

func SetHeartbeatTime Uses

func SetHeartbeatTime(interval time.Duration)

SetHeartbeatTime sets the heartbeat time 设置心跳时间

func SetLogger Uses

func SetLogger(l logger.Logger)

SetLogger logger setter

func SetPacketDecoder Uses

func SetPacketDecoder(d codec.PacketDecoder)

SetPacketDecoder更改用于解析接收到的消息的解码器

func SetPacketEncoder Uses

func SetPacketEncoder(e codec.PacketEncoder)

SetPacketEncoder changes the encoder used to package outgoing messages SetPacketEncoder改变了用于打包输出消息的编码器

func SetRPCClient Uses

func SetRPCClient(s cluster.RPCClient)

SetRPCClient to be used 使用setrlient

func SetRPCServer Uses

func SetRPCServer(s cluster.RPCServer)

SetRPCServer to be used 使用SetRPCServer

func SetSerializer Uses

func SetSerializer(seri serialize.Serializer)

SetSerializer customize application serializer, which automatically Marshal and UnMarshal handler payload SetSerializer自定义应用程序序列化器,它会自动封送 以及解封处理程序负载

func SetServiceDiscoveryClient Uses

func SetServiceDiscoveryClient(s cluster.ServiceDiscovery)

SetServiceDiscoveryClient to be used 要使用的SetServiceDiscoveryClient

func SetTimerBacklog Uses

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. SetTimerBacklog设置计时器创建/关闭通道backlog,一个小的backlog 当调用NewTimer/NewCountTimer/timer.Stop时,可能会导致逻辑被阻塞 在主逻辑中。

func SetTimerPrecision Uses

func SetTimerPrecision(precision time.Duration)

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 Uses

func Shutdown()

Shutdown send a signal to let 'pitaya' shutdown itself. 关机发送一个信号让火龙果自己关机。

func Start Uses

func Start()

Start starts the app 启动应用程序

func StartWorker Uses

func StartWorker(config *config.Config) error

StartWorker configures, starts and returns pitaya worker StartWorker配置、启动和返回火龙果工作程序

type App Uses

type App struct {
    // contains filtered or unexported fields
}

App is the base app struct App是基础的App结构体

type ServerMode Uses

type ServerMode byte

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
)

Directories

PathSynopsis
acceptor
acceptorwrapper
agent
client
cluster
cluster/mocksPackage mocks is a generated GoMock package.
component
config
conn/codec
conn/codec/mocksPackage mocks is a generated GoMock package.
conn/message
conn/message/mocksPackage mocks is a generated GoMock package.
conn/packet
constants
context
defaultpipelines
docgenerator
errors
examples/demo/chat
examples/demo/cluster
examples/demo/cluster_grpc
examples/demo/cluster_grpc/services
examples/demo/cluster_protobuf
examples/demo/cluster_protobuf/protos
examples/demo/cluster_protobuf/services
examples/demo/cluster/services
examples/demo/custom_metrics
examples/demo/custom_metrics/messages
examples/demo/custom_metrics/services
examples/demo/pipeline
examples/demo/protos
examples/demo/rate_limiting
examples/demo/rate_limiting/services
examples/demo/worker
examples/demo/worker/protos
examples/demo/worker/services
examples/testing
examples/testing/protos
groups
helpers
interfaces
interfaces/mocksPackage mocks is a generated GoMock package.
logger
metrics
metrics/mocksPackage mocks is a generated GoMock package.
mocksPackage mock_acceptor is a generated GoMock package.
modules
pipeline
protos
protos/mocksPackage mocks is a generated GoMock package.
protos/test
remote
route
router
serialize
serialize/json
serialize/mocksPackage mocks is a generated GoMock package.
serialize/protobuf
service
session
session/mocksPackage mocks is a generated GoMock package.
timer
tracing
tracing/jaeger
util
util/compression
worker
worker/mocksPackage mocks is a generated GoMock package.

Package pitaya imports 43 packages (graph) and is imported by 24 packages. Updated 26 days ago. Refresh now. Tools for package owners.

原文