title: "pitaya API doc" date: 2023-08-02T16:11:48+07:00
從源代碼整理,基於 pitaya v2.6.1。和官方文檔不衝突
func NewTimer(interval time.Duration, fn timer.Func) *timer.Timer func NewCountTimer(interval time.Duration, count int, fn timer.Func) *timer.Timer func NewAfterTimer(duration time.Duration, fn timer.Func) *timer.Timer func NewCondTimer(condition timer.Condition, fn timer.Func) (*timer.Timer, error) func SetTimerPrecision(precision time.Duration) func SetTimerBacklog(c int)
func Configure(isFrontend bool, serverType string, serverMode ServerMode, serverMetadata map[string]string, cfgs ...*viper.Viper) func GetDieChan() chan bool func SetDebug(debug bool) func SetHeartbeatTime(interval time.Duration) func GetServerID() string func GetMetricsReporters() []metrics.Reporter func GetServer() *cluster.Server func GetServerByID(id string) (*cluster.Server, error) func GetServersByType(t string) (map[string]*cluster.Server, error) func GetServers() []*cluster.Server func GetSessionFromCtx(ctx context.Context) session.Session func Start() func SetDictionary(dict map[string]uint16) error func AddRoute(serverType string, routingFunction router.RoutingFunc) error func Shutdown() func StartWorker() func RegisterRPCJob(rpcJob worker.RPCJob) error func Documentation(getPtrNames bool) (map[string]interface{}, error) func IsRunning() bool 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, arg proto.Message) error func ReliableRPC(routeStr string, metadata map[string]interface{}, reply, arg proto.Message) (jid string, err error) func ReliableRPCWithOptions(routeStr string, metadata map[string]interface{}, reply, arg proto.Message, opts *config.EnqueueOpts) (jidstring, err error) func SendPushToUsers(route string, v interface{}, uids []string, frontendType string) ([]string, error) func SendKickToUsers(uids []string, frontendType string) ([]string, error) func GroupCreate(ctx context.Context, groupName string) error func GroupCreateWithTTL(ctx context.Context, groupName string, ttlTime time.Duration) error func GroupMembers(ctx context.Context, groupName string) ([]string, error) func GroupBroadcast(ctx context.Context, frontendType, groupName, route string, v interface{}) error func GroupContainsMember(ctx context.Context, groupName, uid string) (bool, error) func GroupAddMember(ctx context.Context, groupName, uid string) error func GroupRemoveMember(ctx context.Context, groupName, uid string) error func GroupRemoveAll(ctx context.Context, groupName string) error func GroupCountMembers(ctx context.Context, groupName string) (int, error) func GroupRenewTTL(ctx context.Context, groupName string) error func GroupDelete(ctx context.Context, groupName string) error func Register(c component.Component, options ...component.Option) func RegisterRemote(c component.Component, options ...component.Option) func RegisterModule(module interfaces.Module, name string) error func RegisterModuleAfter(module interfaces.Module, name string) error func RegisterModuleBefore(module interfaces.Module, name string) error func GetModule(name string) (interfaces.Module, error) func NewApp(
serverMode ServerMode,
serializer serialize.Serializer,
acceptors []acceptor.Acceptor,
dieChan chan bool,
router *router.Router,
server *cluster.Server,
rpcClient cluster.RPCClient,
rpcServer cluster.RPCServer,
worker *worker.Worker,
serviceDiscovery cluster.ServiceDiscovery,
remoteService *service.RemoteService,
handlerService *service.HandlerService,
groups groups.GroupService,
sessionPool session.SessionPool,
metricsReporters []metrics.Reporter,
config config.PitayaConfig,
) *App