api

package
v1.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserIDKey    contextKey = "user_id"
	UsernameKey  contextKey = "username"
	RequestIDKey contextKey = "request_id"
)

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(tm *auth.TokenManager) func(http.Handler) http.Handler

AuthMiddleware extracts and validates Bearer JWT token from Authorization header.

func BodyLimitMiddleware

func BodyLimitMiddleware(maxBytes int64) func(http.Handler) http.Handler

BodyLimitMiddleware restricts request body size.

func CORSMiddleware

func CORSMiddleware(allowedOrigins []string) func(http.Handler) http.Handler

CORSMiddleware handles CORS with a configurable origin allowlist. Empty origins or a single "*" entry allows any origin (development default).

func GRPCHookUnaryInterceptor

func GRPCHookUnaryInterceptor(rm *runtime.GoRuntimeManager, luaVM *lua.LState, jsVM *goja.Runtime) grpc.UnaryServerInterceptor

GRPCHookUnaryInterceptor returns a unary interceptor executing before/after hooks.

func GRPCMetricsUnaryInterceptor

func GRPCMetricsUnaryInterceptor() grpc.UnaryServerInterceptor

GRPCMetricsUnaryInterceptor records gRPC request counts for Prometheus.

func HTTPHookMiddleware

func HTTPHookMiddleware(rm *runtime.GoRuntimeManager, luaVM *lua.LState, jsVM *goja.Runtime, next http.HandlerFunc) http.HandlerFunc

HTTPHookMiddleware wraps a REST handler to intercept requests and responses with before/after hooks.

func MetricsMiddleware

func MetricsMiddleware(next http.Handler) http.Handler

MetricsMiddleware records HTTP request counts for Prometheus.

func RateLimitMiddleware

func RateLimitMiddleware(limiter RateLimiter) func(http.Handler) http.Handler

RateLimitMiddleware blocks requests when the rate limit for the client IP is exceeded.

func RequestIDMiddleware

func RequestIDMiddleware(next http.Handler) http.Handler

RequestIDMiddleware echoes or generates X-Request-Id.

func SecurityHeadersMiddleware

func SecurityHeadersMiddleware(next http.Handler) http.Handler

SecurityHeadersMiddleware adds standard security headers to HTTP responses.

Types

type ApiServer

type ApiServer struct {
	apipb.UnimplementedUltimateGameEngineServer
	// contains filtered or unexported fields
}

ApiServer implements apipb.UltimateGameEngineServer by delegating RPC requests to domain sub-servers.

func NewApiServer

func NewApiServer(
	authServer *AuthServer,
	storageServer *StorageServer,
	leaderboardServer *LeaderboardServer,
	tournamentServer *TournamentServer,
	friendsServer *FriendsServer,
	groupServer *GroupServer,
	matchmakerServer *MatchmakerServer,
	realtimeServer *RealtimeServer,
	partyServer *PartyServer,
	channelServer *ChannelServer,
	notificationServer *NotificationServer,
	iapServer *IAPServer,
	rpcServer *RpcServer,
	userServer *UserServer,
	systemServer *SystemServer,
	eventServer *EventServer,
) *ApiServer

func (*ApiServer) AddFriends

func (s *ApiServer) AddFriends(ctx context.Context, req *apipb.AddFriendsRequest) (*emptypb.Empty, error)

func (*ApiServer) AddGroupUsers

func (s *ApiServer) AddGroupUsers(ctx context.Context, req *apipb.AddGroupUsersRequest) (*emptypb.Empty, error)

func (*ApiServer) AuthenticateApple

func (s *ApiServer) AuthenticateApple(ctx context.Context, req *apipb.AuthenticateAppleRequest) (*apipb.Session, error)

func (*ApiServer) AuthenticateCustom

func (s *ApiServer) AuthenticateCustom(ctx context.Context, req *apipb.AuthenticateCustomRequest) (*apipb.Session, error)

func (*ApiServer) AuthenticateDevice

func (s *ApiServer) AuthenticateDevice(ctx context.Context, req *apipb.AuthenticateDeviceRequest) (*apipb.Session, error)

func (*ApiServer) AuthenticateEmail

func (s *ApiServer) AuthenticateEmail(ctx context.Context, req *apipb.AuthenticateEmailRequest) (*apipb.Session, error)

func (*ApiServer) AuthenticateFacebook

func (s *ApiServer) AuthenticateFacebook(ctx context.Context, req *apipb.AuthenticateFacebookRequest) (*apipb.Session, error)

func (*ApiServer) AuthenticateFacebookInstantGame

func (s *ApiServer) AuthenticateFacebookInstantGame(ctx context.Context, req *apipb.AuthenticateFacebookInstantGameRequest) (*apipb.Session, error)

func (*ApiServer) AuthenticateGameCenter

func (s *ApiServer) AuthenticateGameCenter(ctx context.Context, req *apipb.AuthenticateGameCenterRequest) (*apipb.Session, error)

func (*ApiServer) AuthenticateGoogle

func (s *ApiServer) AuthenticateGoogle(ctx context.Context, req *apipb.AuthenticateGoogleRequest) (*apipb.Session, error)

func (*ApiServer) AuthenticateSteam

func (s *ApiServer) AuthenticateSteam(ctx context.Context, req *apipb.AuthenticateSteamRequest) (*apipb.Session, error)

func (*ApiServer) BanGroupUsers

func (s *ApiServer) BanGroupUsers(ctx context.Context, req *apipb.BanGroupUsersRequest) (*emptypb.Empty, error)

func (*ApiServer) BlockFriends

func (s *ApiServer) BlockFriends(ctx context.Context, req *apipb.BlockFriendsRequest) (*emptypb.Empty, error)

func (*ApiServer) CreateGroup

func (s *ApiServer) CreateGroup(ctx context.Context, req *apipb.CreateGroupRequest) (*apipb.Group, error)

func (*ApiServer) DeleteAccount

func (s *ApiServer) DeleteAccount(ctx context.Context, req *emptypb.Empty) (*emptypb.Empty, error)

func (*ApiServer) DeleteFriends

func (s *ApiServer) DeleteFriends(ctx context.Context, req *apipb.DeleteFriendsRequest) (*emptypb.Empty, error)

func (*ApiServer) DeleteGroup

func (s *ApiServer) DeleteGroup(ctx context.Context, req *apipb.DeleteGroupRequest) (*emptypb.Empty, error)

func (*ApiServer) DeleteLeaderboardRecord

func (s *ApiServer) DeleteLeaderboardRecord(ctx context.Context, req *apipb.DeleteLeaderboardRecordRequest) (*emptypb.Empty, error)

func (*ApiServer) DeleteNotifications

func (s *ApiServer) DeleteNotifications(ctx context.Context, req *apipb.DeleteNotificationsRequest) (*emptypb.Empty, error)

func (*ApiServer) DeleteStorageObjects

func (s *ApiServer) DeleteStorageObjects(ctx context.Context, req *apipb.DeleteStorageObjectsRequest) (*emptypb.Empty, error)

func (*ApiServer) DeleteTournamentRecord

func (s *ApiServer) DeleteTournamentRecord(ctx context.Context, req *apipb.DeleteTournamentRecordRequest) (*emptypb.Empty, error)

func (*ApiServer) DemoteGroupUsers

func (s *ApiServer) DemoteGroupUsers(ctx context.Context, req *apipb.DemoteGroupUsersRequest) (*emptypb.Empty, error)

func (*ApiServer) Event

func (s *ApiServer) Event(ctx context.Context, req *apipb.Event) (*emptypb.Empty, error)

func (*ApiServer) GetAccount

func (s *ApiServer) GetAccount(ctx context.Context, req *emptypb.Empty) (*apipb.Account, error)

func (*ApiServer) GetMatchmakerStats

func (s *ApiServer) GetMatchmakerStats(ctx context.Context, req *emptypb.Empty) (*apipb.MatchmakerStats, error)

func (*ApiServer) GetSubscription

func (*ApiServer) GetUsers

func (s *ApiServer) GetUsers(ctx context.Context, req *apipb.GetUsersRequest) (*apipb.Users, error)

func (*ApiServer) Healthcheck

func (s *ApiServer) Healthcheck(ctx context.Context, req *emptypb.Empty) (*emptypb.Empty, error)

func (*ApiServer) ImportFacebookFriends

func (s *ApiServer) ImportFacebookFriends(ctx context.Context, req *apipb.ImportFacebookFriendsRequest) (*emptypb.Empty, error)

func (*ApiServer) ImportSteamFriends

func (s *ApiServer) ImportSteamFriends(ctx context.Context, req *apipb.ImportSteamFriendsRequest) (*emptypb.Empty, error)

func (*ApiServer) JoinGroup

func (s *ApiServer) JoinGroup(ctx context.Context, req *apipb.JoinGroupRequest) (*emptypb.Empty, error)

func (*ApiServer) JoinTournament

func (s *ApiServer) JoinTournament(ctx context.Context, req *apipb.JoinTournamentRequest) (*emptypb.Empty, error)

func (*ApiServer) KickGroupUsers

func (s *ApiServer) KickGroupUsers(ctx context.Context, req *apipb.KickGroupUsersRequest) (*emptypb.Empty, error)

func (*ApiServer) LeaveGroup

func (s *ApiServer) LeaveGroup(ctx context.Context, req *apipb.LeaveGroupRequest) (*emptypb.Empty, error)

func (*ApiServer) LinkApple

func (s *ApiServer) LinkApple(ctx context.Context, req *apipb.AccountApple) (*emptypb.Empty, error)

func (*ApiServer) LinkCustom

func (s *ApiServer) LinkCustom(ctx context.Context, req *apipb.AccountCustom) (*emptypb.Empty, error)

func (*ApiServer) LinkDevice

func (s *ApiServer) LinkDevice(ctx context.Context, req *apipb.AccountDevice) (*emptypb.Empty, error)

func (*ApiServer) LinkEmail

func (s *ApiServer) LinkEmail(ctx context.Context, req *apipb.AccountEmail) (*emptypb.Empty, error)

func (*ApiServer) LinkFacebook

func (s *ApiServer) LinkFacebook(ctx context.Context, req *apipb.LinkFacebookRequest) (*emptypb.Empty, error)

func (*ApiServer) LinkFacebookInstantGame

func (s *ApiServer) LinkFacebookInstantGame(ctx context.Context, req *apipb.AccountFacebookInstantGame) (*emptypb.Empty, error)

func (*ApiServer) LinkGameCenter

func (s *ApiServer) LinkGameCenter(ctx context.Context, req *apipb.AccountGameCenter) (*emptypb.Empty, error)

func (*ApiServer) LinkGoogle

func (s *ApiServer) LinkGoogle(ctx context.Context, req *apipb.AccountGoogle) (*emptypb.Empty, error)

func (*ApiServer) LinkSteam

func (s *ApiServer) LinkSteam(ctx context.Context, req *apipb.LinkSteamRequest) (*emptypb.Empty, error)

func (*ApiServer) ListChannelMessages

func (*ApiServer) ListFriends

func (s *ApiServer) ListFriends(ctx context.Context, req *apipb.ListFriendsRequest) (*apipb.FriendList, error)

func (*ApiServer) ListFriendsOfFriends

func (*ApiServer) ListGroupUsers

func (s *ApiServer) ListGroupUsers(ctx context.Context, req *apipb.ListGroupUsersRequest) (*apipb.GroupUserList, error)

func (*ApiServer) ListGroups

func (s *ApiServer) ListGroups(ctx context.Context, req *apipb.ListGroupsRequest) (*apipb.GroupList, error)

func (*ApiServer) ListLeaderboardRecords

func (*ApiServer) ListMatches

func (s *ApiServer) ListMatches(ctx context.Context, req *apipb.ListMatchesRequest) (*apipb.MatchList, error)

func (*ApiServer) ListNotifications

func (s *ApiServer) ListNotifications(ctx context.Context, req *apipb.ListNotificationsRequest) (*apipb.NotificationList, error)

func (*ApiServer) ListParties

func (s *ApiServer) ListParties(ctx context.Context, req *apipb.ListPartiesRequest) (*apipb.PartyList, error)

func (*ApiServer) ListStorageObjects

func (*ApiServer) ListSubscriptions

func (s *ApiServer) ListSubscriptions(ctx context.Context, req *apipb.ListSubscriptionsRequest) (*apipb.SubscriptionList, error)

func (*ApiServer) ListTournamentRecords

func (*ApiServer) ListTournaments

func (s *ApiServer) ListTournaments(ctx context.Context, req *apipb.ListTournamentsRequest) (*apipb.TournamentList, error)

func (*ApiServer) ListUserGroups

func (s *ApiServer) ListUserGroups(ctx context.Context, req *apipb.ListUserGroupsRequest) (*apipb.UserGroupList, error)

func (*ApiServer) PromoteGroupUsers

func (s *ApiServer) PromoteGroupUsers(ctx context.Context, req *apipb.PromoteGroupUsersRequest) (*emptypb.Empty, error)

func (*ApiServer) ReadStorageObjects

func (s *ApiServer) ReadStorageObjects(ctx context.Context, req *apipb.ReadStorageObjectsRequest) (*apipb.StorageObjects, error)

func (*ApiServer) RpcFunc

func (s *ApiServer) RpcFunc(ctx context.Context, req *apipb.Rpc) (*apipb.Rpc, error)

func (*ApiServer) SessionLogout

func (s *ApiServer) SessionLogout(ctx context.Context, req *apipb.SessionLogoutRequest) (*emptypb.Empty, error)

func (*ApiServer) SessionRefresh

func (s *ApiServer) SessionRefresh(ctx context.Context, req *apipb.SessionRefreshRequest) (*apipb.Session, error)

func (*ApiServer) UnlinkApple

func (s *ApiServer) UnlinkApple(ctx context.Context, req *apipb.AccountApple) (*emptypb.Empty, error)

func (*ApiServer) UnlinkCustom

func (s *ApiServer) UnlinkCustom(ctx context.Context, req *apipb.AccountCustom) (*emptypb.Empty, error)

func (*ApiServer) UnlinkDevice

func (s *ApiServer) UnlinkDevice(ctx context.Context, req *apipb.AccountDevice) (*emptypb.Empty, error)

func (*ApiServer) UnlinkEmail

func (s *ApiServer) UnlinkEmail(ctx context.Context, req *apipb.AccountEmail) (*emptypb.Empty, error)

func (*ApiServer) UnlinkFacebook

func (s *ApiServer) UnlinkFacebook(ctx context.Context, req *apipb.AccountFacebook) (*emptypb.Empty, error)

func (*ApiServer) UnlinkFacebookInstantGame

func (s *ApiServer) UnlinkFacebookInstantGame(ctx context.Context, req *apipb.AccountFacebookInstantGame) (*emptypb.Empty, error)

func (*ApiServer) UnlinkGameCenter

func (s *ApiServer) UnlinkGameCenter(ctx context.Context, req *apipb.AccountGameCenter) (*emptypb.Empty, error)

func (*ApiServer) UnlinkGoogle

func (s *ApiServer) UnlinkGoogle(ctx context.Context, req *apipb.AccountGoogle) (*emptypb.Empty, error)

func (*ApiServer) UnlinkSteam

func (s *ApiServer) UnlinkSteam(ctx context.Context, req *apipb.AccountSteam) (*emptypb.Empty, error)

func (*ApiServer) UpdateAccount

func (s *ApiServer) UpdateAccount(ctx context.Context, req *apipb.UpdateAccountRequest) (*emptypb.Empty, error)

func (*ApiServer) UpdateGroup

func (s *ApiServer) UpdateGroup(ctx context.Context, req *apipb.UpdateGroupRequest) (*emptypb.Empty, error)

func (*ApiServer) ValidatePurchaseApple

func (*ApiServer) ValidatePurchaseGoogle

func (*ApiServer) ValidatePurchaseHuawei

func (*ApiServer) ValidatePurchaseSamsung

func (*ApiServer) WriteLeaderboardRecord

func (s *ApiServer) WriteLeaderboardRecord(ctx context.Context, req *apipb.WriteLeaderboardRecordRequest) (*apipb.LeaderboardRecord, error)

func (*ApiServer) WriteStorageObjects

func (s *ApiServer) WriteStorageObjects(ctx context.Context, req *apipb.WriteStorageObjectsRequest) (*apipb.StorageObjectAcks, error)

func (*ApiServer) WriteTournamentRecord

func (s *ApiServer) WriteTournamentRecord(ctx context.Context, req *apipb.WriteTournamentRecordRequest) (*apipb.LeaderboardRecord, error)

type AuthServer

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

AuthServer implements authentication, session, and account RPCs.

func NewAuthServer

func NewAuthServer(api *Server) *AuthServer

NewAuthServer wraps the HTTP API server for shared session/DB state.

func (*AuthServer) AuthenticateApple

func (s *AuthServer) AuthenticateApple(ctx context.Context, req *apipb.AuthenticateAppleRequest) (*apipb.Session, error)

func (*AuthServer) AuthenticateCustom

func (s *AuthServer) AuthenticateCustom(ctx context.Context, req *apipb.AuthenticateCustomRequest) (*apipb.Session, error)

func (*AuthServer) AuthenticateDevice

func (s *AuthServer) AuthenticateDevice(ctx context.Context, req *apipb.AuthenticateDeviceRequest) (*apipb.Session, error)

func (*AuthServer) AuthenticateEmail

func (s *AuthServer) AuthenticateEmail(ctx context.Context, req *apipb.AuthenticateEmailRequest) (*apipb.Session, error)

func (*AuthServer) AuthenticateFacebook

func (s *AuthServer) AuthenticateFacebook(ctx context.Context, req *apipb.AuthenticateFacebookRequest) (*apipb.Session, error)

func (*AuthServer) AuthenticateFacebookInstantGame

func (s *AuthServer) AuthenticateFacebookInstantGame(ctx context.Context, req *apipb.AuthenticateFacebookInstantGameRequest) (*apipb.Session, error)

func (*AuthServer) AuthenticateGameCenter

func (s *AuthServer) AuthenticateGameCenter(ctx context.Context, req *apipb.AuthenticateGameCenterRequest) (*apipb.Session, error)

func (*AuthServer) AuthenticateGoogle

func (s *AuthServer) AuthenticateGoogle(ctx context.Context, req *apipb.AuthenticateGoogleRequest) (*apipb.Session, error)

func (*AuthServer) AuthenticateSteam

func (s *AuthServer) AuthenticateSteam(ctx context.Context, req *apipb.AuthenticateSteamRequest) (*apipb.Session, error)

func (*AuthServer) DeleteAccount

func (s *AuthServer) DeleteAccount(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)

func (*AuthServer) GetAccount

func (s *AuthServer) GetAccount(ctx context.Context, _ *emptypb.Empty) (*apipb.Account, error)

func (*AuthServer) LinkApple

func (s *AuthServer) LinkApple(ctx context.Context, req *apipb.AccountApple) (*emptypb.Empty, error)

func (*AuthServer) LinkCustom

func (s *AuthServer) LinkCustom(ctx context.Context, req *apipb.AccountCustom) (*emptypb.Empty, error)

func (*AuthServer) LinkDevice

func (s *AuthServer) LinkDevice(ctx context.Context, req *apipb.AccountDevice) (*emptypb.Empty, error)

func (*AuthServer) LinkEmail

func (s *AuthServer) LinkEmail(ctx context.Context, req *apipb.AccountEmail) (*emptypb.Empty, error)

func (*AuthServer) LinkFacebook

func (s *AuthServer) LinkFacebook(ctx context.Context, req *apipb.LinkFacebookRequest) (*emptypb.Empty, error)

func (*AuthServer) LinkFacebookInstantGame

func (s *AuthServer) LinkFacebookInstantGame(ctx context.Context, req *apipb.AccountFacebookInstantGame) (*emptypb.Empty, error)

func (*AuthServer) LinkGameCenter

func (s *AuthServer) LinkGameCenter(ctx context.Context, req *apipb.AccountGameCenter) (*emptypb.Empty, error)

func (*AuthServer) LinkGoogle

func (s *AuthServer) LinkGoogle(ctx context.Context, req *apipb.AccountGoogle) (*emptypb.Empty, error)

func (*AuthServer) LinkSteam

func (s *AuthServer) LinkSteam(ctx context.Context, req *apipb.LinkSteamRequest) (*emptypb.Empty, error)

func (*AuthServer) SessionLogout

func (s *AuthServer) SessionLogout(ctx context.Context, req *apipb.SessionLogoutRequest) (*emptypb.Empty, error)

func (*AuthServer) SessionRefresh

func (s *AuthServer) SessionRefresh(ctx context.Context, req *apipb.SessionRefreshRequest) (*apipb.Session, error)

func (*AuthServer) UnlinkApple

func (s *AuthServer) UnlinkApple(ctx context.Context, _ *apipb.AccountApple) (*emptypb.Empty, error)

func (*AuthServer) UnlinkCustom

func (s *AuthServer) UnlinkCustom(ctx context.Context, _ *apipb.AccountCustom) (*emptypb.Empty, error)

func (*AuthServer) UnlinkDevice

func (s *AuthServer) UnlinkDevice(ctx context.Context, req *apipb.AccountDevice) (*emptypb.Empty, error)

func (*AuthServer) UnlinkEmail

func (s *AuthServer) UnlinkEmail(ctx context.Context, _ *apipb.AccountEmail) (*emptypb.Empty, error)

func (*AuthServer) UnlinkFacebook

func (s *AuthServer) UnlinkFacebook(ctx context.Context, _ *apipb.AccountFacebook) (*emptypb.Empty, error)

func (*AuthServer) UnlinkFacebookInstantGame

func (s *AuthServer) UnlinkFacebookInstantGame(ctx context.Context, _ *apipb.AccountFacebookInstantGame) (*emptypb.Empty, error)

func (*AuthServer) UnlinkGameCenter

func (s *AuthServer) UnlinkGameCenter(ctx context.Context, _ *apipb.AccountGameCenter) (*emptypb.Empty, error)

func (*AuthServer) UnlinkGoogle

func (s *AuthServer) UnlinkGoogle(ctx context.Context, _ *apipb.AccountGoogle) (*emptypb.Empty, error)

func (*AuthServer) UnlinkSteam

func (s *AuthServer) UnlinkSteam(ctx context.Context, _ *apipb.AccountSteam) (*emptypb.Empty, error)

func (*AuthServer) UpdateAccount

func (s *AuthServer) UpdateAccount(ctx context.Context, req *apipb.UpdateAccountRequest) (*emptypb.Empty, error)

type ChannelServer

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

ChannelServer implements apipb.ChatServiceServer.

func NewChannelServer

func NewChannelServer(pool *pgxpool.Pool, tm *auth.TokenManager, hooks *runtime.HookRegistry) *ChannelServer

NewChannelServer creates a ChannelServer.

func (*ChannelServer) ListChannelMessages

ListChannelMessages lists persistent channel history.

type Config

type Config struct {
	HTTPAddr                 string              `json:"http_addr" yaml:"http_addr"`
	GRPCAddr                 string              `json:"grpc_addr" yaml:"grpc_addr"`
	JWTSecret                []byte              `json:"jwt_secret" yaml:"jwt_secret"`
	JWTExpiry                time.Duration       `json:"jwt_expiry" yaml:"jwt_expiry"`
	RateLimitMax             float64             `json:"rate_limit_max" yaml:"rate_limit_max"`
	RateLimitRefill          float64             `json:"rate_limit_refill" yaml:"rate_limit_refill"`
	BodyLimitBytes           int64               `json:"body_limit_bytes" yaml:"body_limit_bytes"`
	CORSOrigins              []string            `json:"cors_allowed_origins" yaml:"cors_allowed_origins"`
	Version                  string              `json:"version" yaml:"version"`
	RPCHTTPKey               string              `json:"rpc_http_key" yaml:"rpc_http_key"`
	RPCTimeoutMs             int                 `json:"rpc_execution_timeout_ms" yaml:"rpc_execution_timeout_ms"`
	RPCMaxPayload            int                 `json:"rpc_max_payload_size_bytes" yaml:"rpc_max_payload_size_bytes"`
	RuntimePath              string              `json:"runtime_path" yaml:"runtime_path"`
	PresenceMaxSubscriptions int                 `json:"presence_max_subscriptions_per_user" yaml:"presence_max_subscriptions_per_user"`
	PresenceMaxStatusBytes   int                 `json:"presence_max_status_bytes" yaml:"presence_max_status_bytes"`
	IAP                      economy.IAPConfig   `json:"iap" yaml:"iap"`
	MultiInstance            MultiInstanceConfig `json:"multi_instance" yaml:"multi_instance"`
}

Config defines the configuration options for the API server.

type DBNotifier

type DBNotifier struct {
	Pool *pgxpool.Pool
}

DBNotifier persists friend notifications via the notification package.

func (DBNotifier) Notify

func (n DBNotifier) Notify(ctx context.Context, userID, subject, content string, code int16, senderID string) error

type EconomyServer

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

func NewEconomyServer

func NewEconomyServer(pool *pgxpool.Pool, tm *auth.TokenManager, hooks *runtime.HookRegistry) *EconomyServer

func (*EconomyServer) SetHooks

func (s *EconomyServer) SetHooks(hooks *runtime.HookRegistry)

type EventServer

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

EventServer implements apipb.EventServiceServer.

func NewEventServer

func NewEventServer(tm *auth.TokenManager, hooks *runtime.HookRegistry, logger runtime.Logger) *EventServer

NewEventServer creates an EventServer.

func (*EventServer) Event

func (s *EventServer) Event(ctx context.Context, req *apipb.Event) (*emptypb.Empty, error)

Event accepts client telemetry and dispatches to runtime event handlers.

func (*EventServer) SetHooks

func (s *EventServer) SetHooks(hooks *runtime.HookRegistry)

SetHooks updates the hook registry.

type FriendsServer

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

func NewFriendsServer

func NewFriendsServer(dbPool *pgxpool.Pool, tokenMgr *auth.TokenManager, pt *presence.PresenceTracker) *FriendsServer

func (*FriendsServer) AddFriends

func (s *FriendsServer) AddFriends(ctx context.Context, req *apipb.AddFriendsRequest) (*emptypb.Empty, error)

func (*FriendsServer) BlockFriends

func (s *FriendsServer) BlockFriends(ctx context.Context, req *apipb.BlockFriendsRequest) (*emptypb.Empty, error)

func (*FriendsServer) DeleteFriends

func (s *FriendsServer) DeleteFriends(ctx context.Context, req *apipb.DeleteFriendsRequest) (*emptypb.Empty, error)

func (*FriendsServer) ImportFacebookFriends

func (s *FriendsServer) ImportFacebookFriends(ctx context.Context, req *apipb.ImportFacebookFriendsRequest) (*emptypb.Empty, error)

func (*FriendsServer) ImportSteamFriends

func (s *FriendsServer) ImportSteamFriends(ctx context.Context, req *apipb.ImportSteamFriendsRequest) (*emptypb.Empty, error)

func (*FriendsServer) ListFriends

func (*FriendsServer) ListFriendsOfFriends

type GroupServer

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

func NewGroupServer

func NewGroupServer(dbPool *pgxpool.Pool, tokenMgr *auth.TokenManager) *GroupServer

func (*GroupServer) AddGroupUsers

func (s *GroupServer) AddGroupUsers(ctx context.Context, req *apipb.AddGroupUsersRequest) (*emptypb.Empty, error)

func (*GroupServer) BanGroupUsers

func (s *GroupServer) BanGroupUsers(ctx context.Context, req *apipb.BanGroupUsersRequest) (*emptypb.Empty, error)

func (*GroupServer) CreateGroup

func (s *GroupServer) CreateGroup(ctx context.Context, req *apipb.CreateGroupRequest) (*apipb.Group, error)

func (*GroupServer) DeleteGroup

func (s *GroupServer) DeleteGroup(ctx context.Context, req *apipb.DeleteGroupRequest) (*emptypb.Empty, error)

func (*GroupServer) DemoteGroupUsers

func (s *GroupServer) DemoteGroupUsers(ctx context.Context, req *apipb.DemoteGroupUsersRequest) (*emptypb.Empty, error)

func (*GroupServer) JoinGroup

func (s *GroupServer) JoinGroup(ctx context.Context, req *apipb.JoinGroupRequest) (*emptypb.Empty, error)

func (*GroupServer) KickGroupUsers

func (s *GroupServer) KickGroupUsers(ctx context.Context, req *apipb.KickGroupUsersRequest) (*emptypb.Empty, error)

func (*GroupServer) LeaveGroup

func (s *GroupServer) LeaveGroup(ctx context.Context, req *apipb.LeaveGroupRequest) (*emptypb.Empty, error)

func (*GroupServer) ListGroupUsers

func (*GroupServer) ListGroups

func (s *GroupServer) ListGroups(ctx context.Context, req *apipb.ListGroupsRequest) (*apipb.GroupList, error)

func (*GroupServer) ListUserGroups

func (*GroupServer) PromoteGroupUsers

func (s *GroupServer) PromoteGroupUsers(ctx context.Context, req *apipb.PromoteGroupUsersRequest) (*emptypb.Empty, error)

func (*GroupServer) SetNotifier

func (s *GroupServer) SetNotifier(n social.FriendNotifier)

SetNotifier configures group notification delivery.

func (*GroupServer) UpdateGroup

func (s *GroupServer) UpdateGroup(ctx context.Context, req *apipb.UpdateGroupRequest) (*emptypb.Empty, error)

type IAPServer

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

IAPServer implements apipb.IAPServiceServer.

func NewIAPServer

func NewIAPServer(pool *pgxpool.Pool, tm *auth.TokenManager, hooks *runtime.HookRegistry, cfg economy.IAPConfig) *IAPServer

func (*IAPServer) GetSubscription

func (*IAPServer) ListSubscriptions

func (s *IAPServer) ListSubscriptions(ctx context.Context, req *apipb.ListSubscriptionsRequest) (*apipb.SubscriptionList, error)

func (*IAPServer) SetConfig

func (s *IAPServer) SetConfig(cfg economy.IAPConfig)

func (*IAPServer) SetHooks

func (s *IAPServer) SetHooks(hooks *runtime.HookRegistry)

func (*IAPServer) ValidatePurchaseApple

func (*IAPServer) ValidatePurchaseGoogle

func (*IAPServer) ValidatePurchaseHuawei

func (*IAPServer) ValidatePurchaseSamsung

type IPTokenBucketRateLimiter

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

IPTokenBucketRateLimiter manages a pool of IP-based rate limiters.

func NewIPRateLimiter

func NewIPRateLimiter(maxTokens, refillRate float64) *IPTokenBucketRateLimiter

NewIPRateLimiter creates a new IPRateLimiter.

func (*IPTokenBucketRateLimiter) Allow

func (lim *IPTokenBucketRateLimiter) Allow(key string) bool

Allow checks if a request from a specific key is allowed.

func (*IPTokenBucketRateLimiter) AllowWithInfo

func (lim *IPTokenBucketRateLimiter) AllowWithInfo(key string) (bool, float64, time.Time)

AllowWithInfo implements RateLimiter.

func (*IPTokenBucketRateLimiter) GetLimiter

func (lim *IPTokenBucketRateLimiter) GetLimiter(key string) *TokenBucket

GetLimiter retrieves or creates a rate limiter for a specific key (e.g. IP address or userID).

func (*IPTokenBucketRateLimiter) MaxTokens

func (lim *IPTokenBucketRateLimiter) MaxTokens() float64

MaxTokens returns the configured bucket capacity.

type LeaderboardServer

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

func NewLeaderboardServer

func NewLeaderboardServer(dbPool *pgxpool.Pool, rdb *redis.Client, tokenMgr *auth.TokenManager) *LeaderboardServer

func (*LeaderboardServer) DeleteLeaderboardRecord

func (s *LeaderboardServer) DeleteLeaderboardRecord(ctx context.Context, req *apipb.DeleteLeaderboardRecordRequest) (*emptypb.Empty, error)

func (*LeaderboardServer) ListLeaderboardRecords

func (*LeaderboardServer) ListLeaderboardRecordsAroundOwner

func (*LeaderboardServer) WriteLeaderboardRecord

type MatchmakerServer

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

func NewMatchmakerServer

func NewMatchmakerServer(mm *matchmaker.Matchmaker, tm *auth.TokenManager, resolver SessionIDResolver) *MatchmakerServer

func (*MatchmakerServer) GetMatchmakerStats

func (s *MatchmakerServer) GetMatchmakerStats(ctx context.Context, _ *emptypb.Empty) (*apipb.MatchmakerStats, error)

GetMatchmakerStats returns aggregate matchmaker statistics (reference-compatible).

type MultiInstanceConfig added in v1.1.1

type MultiInstanceConfig struct {
	Enabled   bool   `json:"enabled" yaml:"enabled"`
	RedisAddr string `json:"redis_addr" yaml:"redis_addr"`
}

type NotificationServer

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

NotificationServer implements apipb.NotificationServiceServer.

func NewNotificationServer

func NewNotificationServer(pool *pgxpool.Pool, tm *auth.TokenManager, hooks *runtime.HookRegistry) *NotificationServer

NewNotificationServer creates a NotificationServer.

func (*NotificationServer) DeleteNotifications

func (s *NotificationServer) DeleteNotifications(ctx context.Context, req *apipb.DeleteNotificationsRequest) (*emptypb.Empty, error)

func (*NotificationServer) ListNotifications

func (*NotificationServer) SetHooks

func (s *NotificationServer) SetHooks(hooks *runtime.HookRegistry)

SetHooks attaches Before/After List/Delete hook registry.

type PartyServer

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

PartyServer implements apipb.PartyServiceServer.

func NewPartyServer

func NewPartyServer(reg *party.Registry, tm *auth.TokenManager) *PartyServer

NewPartyServer creates a PartyServer.

func (*PartyServer) ListParties

func (s *PartyServer) ListParties(ctx context.Context, req *apipb.ListPartiesRequest) (*apipb.PartyList, error)

ListParties lists discoverable parties.

type RateLimiter

type RateLimiter interface {
	MaxTokens() float64
	AllowWithInfo(key string) (allowed bool, remaining float64, resetAt time.Time)
}

RateLimiter is implemented by in-memory and Redis-backed API rate limiters.

type RealtimeServer

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

RealtimeServer implements apipb.RealtimeServiceServer.

func NewRealtimeServer

func NewRealtimeServer(logger *zap.Logger, matchRouter *match.Router, rdb *redis.Client, tm *auth.TokenManager) *RealtimeServer

NewRealtimeServer creates a new RealtimeServer instance.

func (*RealtimeServer) ListMatches

ListMatches queries active matches.

type RedisIPRateLimiter

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

Falls back to in-memory token bucket when Redis is unavailable.

func NewRedisIPRateLimiter

func NewRedisIPRateLimiter(rdb *redis.Client, maxTokens, refillRate float64, window time.Duration) *RedisIPRateLimiter

NewRedisIPRateLimiter creates a cluster-aware rate limiter with local fallback.

func (*RedisIPRateLimiter) Allow

func (lim *RedisIPRateLimiter) Allow(key string) bool

Allow checks if a request is allowed for the key.

func (*RedisIPRateLimiter) AllowWithInfo

func (lim *RedisIPRateLimiter) AllowWithInfo(key string) (bool, float64, time.Time)

RedisIPRateLimiter applies a fixed-window counter per key using Redis INCR. AllowWithInfo returns allowance, remaining tokens, and reset time.

func (*RedisIPRateLimiter) MaxTokens

func (lim *RedisIPRateLimiter) MaxTokens() float64

MaxTokens returns configured bucket capacity.

type RpcServer

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

RpcServer implements apipb.RpcServiceServer.

func (*RpcServer) RpcFunc

func (s *RpcServer) RpcFunc(ctx context.Context, req *apipb.Rpc) (*apipb.Rpc, error)

func (*RpcServer) SetRuntime

func (s *RpcServer) SetRuntime(rm *runtime.GoRuntimeManager)

func (*RpcServer) SetVMs

func (s *RpcServer) SetVMs(luaVM *lua.LState, jsVM *goja.Runtime)

type Server

type Server struct {
	SocketRegistry *socket.ConnectionRegistry
	SocketGateway  *socket.GatewayHandler
	MatchRouter    *match.Router
	Matchmaker     *matchmaker.Matchmaker
	PartyRegistry  *party.Registry

	RuntimeManager *runtime.GoRuntimeManager
	LuaVM          *lua.LState
	JSVM           *goja.Runtime

	TournamentScheduler *tournament.TournamentScheduler
	// contains filtered or unexported fields
}

Server handles HTTP and gRPC network interfaces.

func NewServer

func NewServer(logger *zap.Logger, cfg Config, dbPool *pgxpool.Pool) (*Server, error)

NewServer creates a new API Server instance.

func (*Server) Redis

func (s *Server) Redis() *redis.Client

Redis returns the optional Redis client.

func (*Server) SessionRegistry

func (s *Server) SessionRegistry() *auth.SessionRegistry

SessionRegistry exposes the session registry for console ban revocation.

func (*Server) SetRuntimeManager

func (s *Server) SetRuntimeManager(rm *runtime.GoRuntimeManager)

SetRuntimeManager configures the runtime manager for hook interceptors.

func (*Server) SetVMs

func (s *Server) SetVMs(luaVM *lua.LState, jsVM *goja.Runtime)

SetVMs configures the Lua and JavaScript VM instances.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start boots the HTTP and gRPC listeners.

func (*Server) StartLifecycle

func (s *Server) StartLifecycle(parent context.Context)

StartLifecycle starts leaderboard invalidation listener, rank trimmer, and tournament scheduler.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop gracefully shuts down the HTTP and gRPC servers.

type SessionIDResolver

type SessionIDResolver func(userID string) string

type StorageServer

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

func NewStorageServer

func NewStorageServer(dbPool *pgxpool.Pool, tokenMgr *auth.TokenManager) *StorageServer

func (*StorageServer) DeleteStorageObjects

func (s *StorageServer) DeleteStorageObjects(ctx context.Context, req *apipb.DeleteStorageObjectsRequest) (*emptypb.Empty, error)

func (*StorageServer) ListStorageObjects

func (*StorageServer) ReadStorageObjects

func (*StorageServer) WriteStorageObjects

type SystemServer

type SystemServer struct{}

SystemServer implements apipb.SystemServiceServer.

func NewSystemServer

func NewSystemServer() *SystemServer

NewSystemServer creates a SystemServer.

func (*SystemServer) Healthcheck

func (s *SystemServer) Healthcheck(ctx context.Context, _ *emptypb.Empty) (*emptypb.Empty, error)

Healthcheck returns OK when the process is serving.

type TokenBucket

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

TokenBucket implements a rate limiter using the Token Bucket algorithm.

func NewTokenBucket

func NewTokenBucket(maxTokens, refillRate float64) *TokenBucket

NewTokenBucket creates a new TokenBucket rate limiter.

func (*TokenBucket) Allow

func (tb *TokenBucket) Allow() bool

Allow checks if a request is allowed, refilling tokens and consuming one if available.

func (*TokenBucket) AllowWithInfo

func (tb *TokenBucket) AllowWithInfo() (allowed bool, remaining float64, resetAt time.Time)

AllowWithInfo consumes one token when available and returns remaining tokens and reset time. Reset is when the bucket is expected to regain at least one token if currently empty.

type TournamentServer

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

func NewTournamentServer

func NewTournamentServer(dbPool *pgxpool.Pool, rdb *redis.Client, tokenMgr *auth.TokenManager) *TournamentServer

func (*TournamentServer) DeleteTournamentRecord

func (s *TournamentServer) DeleteTournamentRecord(ctx context.Context, req *apipb.DeleteTournamentRecordRequest) (*emptypb.Empty, error)

func (*TournamentServer) JoinTournament

func (s *TournamentServer) JoinTournament(ctx context.Context, req *apipb.JoinTournamentRequest) (*emptypb.Empty, error)

func (*TournamentServer) ListTournamentRecords

func (*TournamentServer) ListTournamentRecordsAroundOwner

func (*TournamentServer) ListTournaments

func (*TournamentServer) WriteTournamentRecord

type UserServer

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

UserServer implements apipb.UserServiceServer.

func NewUserServer

func NewUserServer(pool *pgxpool.Pool, tm *auth.TokenManager) *UserServer

NewUserServer creates a UserServer.

func (*UserServer) GetUsers

func (s *UserServer) GetUsers(ctx context.Context, req *apipb.GetUsersRequest) (*apipb.Users, error)

GetUsers returns public user profiles by id, username, or facebook id.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL