Loading CHANGELOG.md +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - Check group max allowed user when promoting a user. - Correct Lua runtime decoding of stream identifying parameters. - Correctly use optional parameters when they are passed to group creation operations. - Lua runtime operations now observe context cancellation while waiting for an available Lua instance. ## [2.2.1] - 2018-11-20 ### Added Loading server/leaderboard_scheduler.go +3 −3 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ WHERE id = $1` // Trigger callback on a goroutine so any extended processing does not block future scheduling. go func() { if err := fn(tournament, int64(tournament.EndActive), int64(tournament.NextReset)); err != nil { if err := fn(ls.ctx, tournament, int64(tournament.EndActive), int64(tournament.NextReset)); err != nil { ls.logger.Warn("Failed to invoke tournament end callback", zap.Error(err)) } }() Loading Loading @@ -327,7 +327,7 @@ WHERE id = $1` if fnTournamentReset != nil { // Trigger callback on a goroutine so any extended processing does not block future scheduling. go func() { if err := fnTournamentReset(tournament, int64(tournament.EndActive), int64(tournament.NextReset)); err != nil { if err := fnTournamentReset(ls.ctx, tournament, int64(tournament.EndActive), int64(tournament.NextReset)); err != nil { ls.logger.Warn("Failed to invoke tournament reset callback", zap.Error(err)) } }() Loading @@ -342,7 +342,7 @@ WHERE id = $1` // Trigger callback on a goroutine so any extended processing does not block future scheduling. go func() { if err := fnLeaderboardReset(leaderboardOrTournament, nextReset); err != nil { if err := fnLeaderboardReset(ls.ctx, leaderboardOrTournament, nextReset); err != nil { ls.logger.Warn("Failed to invoke leaderboard reset callback", zap.Error(err)) } }() Loading server/pipeline_matchmaker.go +2 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package server import ( "context" "fmt" "time" Loading Loading @@ -79,7 +80,7 @@ func (p *Pipeline) matchmakerAdd(logger *zap.Logger, session Session, envelope * // Check if there's a matchmaker matched runtime callback, call it, and see if it returns a match ID. fn := p.runtime.MatchmakerMatched() if fn != nil { tokenOrMatchID, isMatchID, err = fn(entries) tokenOrMatchID, isMatchID, err = fn(context.Background(), entries) if err != nil { p.logger.Error("Error running Matchmaker Matched hook.", zap.Error(err)) } Loading server/runtime.go +4 −4 Original line number Diff line number Diff line Loading @@ -161,15 +161,15 @@ type ( RuntimeBeforeGetUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, expiry int64, clientIP, clientPort string, in *api.GetUsersRequest) (*api.GetUsersRequest, error, codes.Code) RuntimeAfterGetUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, expiry int64, clientIP, clientPort string, out *api.Users, in *api.GetUsersRequest) error RuntimeMatchmakerMatchedFunction func(entries []*MatchmakerEntry) (string, bool, error) RuntimeMatchmakerMatchedFunction func(ctx context.Context, entries []*MatchmakerEntry) (string, bool, error) RuntimeMatchCreateFunction func(ctx context.Context, logger *zap.Logger, id uuid.UUID, node string, name string) (RuntimeMatchCore, error) RuntimeMatchDeferMessageFunction func(msg *DeferredMessage) error RuntimeTournamentEndFunction func(tournament *api.Tournament, end, reset int64) error RuntimeTournamentResetFunction func(tournament *api.Tournament, end, reset int64) error RuntimeTournamentEndFunction func(ctx context.Context, tournament *api.Tournament, end, reset int64) error RuntimeTournamentResetFunction func(ctx context.Context, tournament *api.Tournament, end, reset int64) error RuntimeLeaderboardResetFunction func(leaderboard runtime.Leaderboard, reset int64) error RuntimeLeaderboardResetFunction func(ctx context.Context, leaderboard runtime.Leaderboard, reset int64) error ) type RuntimeExecutionMode int Loading server/runtime_go.go +8 −8 Original line number Diff line number Diff line Loading @@ -1690,8 +1690,8 @@ func (ri *RuntimeGoInitializer) RegisterAfterGetUsers(fn func(ctx context.Contex } func (ri *RuntimeGoInitializer) RegisterMatchmakerMatched(fn func(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, entries []runtime.MatchmakerEntry) (string, error)) error { ri.matchmakerMatched = func(entries []*MatchmakerEntry) (string, bool, error) { ctx := NewRuntimeGoContext(context.Background(), ri.env, RuntimeExecutionModeMatchmaker, nil, 0, "", "", "", "", "") ri.matchmakerMatched = func(ctx context.Context, entries []*MatchmakerEntry) (string, bool, error) { ctx = NewRuntimeGoContext(ctx, ri.env, RuntimeExecutionModeMatchmaker, nil, 0, "", "", "", "", "") runtimeEntries := make([]runtime.MatchmakerEntry, len(entries)) for i, entry := range entries { runtimeEntries[i] = runtime.MatchmakerEntry(entry) Loading @@ -1706,24 +1706,24 @@ func (ri *RuntimeGoInitializer) RegisterMatchmakerMatched(fn func(ctx context.Co } func (ri *RuntimeGoInitializer) RegisterTournamentEnd(fn func(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, tournament *api.Tournament, end, reset int64) error) error { ri.tournamentEnd = func(tournament *api.Tournament, end, reset int64) error { ctx := NewRuntimeGoContext(context.Background(), ri.env, RuntimeExecutionModeTournamentEnd, nil, 0, "", "", "", "", "") ri.tournamentEnd = func(ctx context.Context, tournament *api.Tournament, end, reset int64) error { ctx = NewRuntimeGoContext(ctx, ri.env, RuntimeExecutionModeTournamentEnd, nil, 0, "", "", "", "", "") return fn(ctx, ri.logger, ri.db, ri.nk, tournament, end, reset) } return nil } func (ri *RuntimeGoInitializer) RegisterTournamentReset(fn func(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, tournament *api.Tournament, end, reset int64) error) error { ri.tournamentReset = func(tournament *api.Tournament, end, reset int64) error { ctx := NewRuntimeGoContext(context.Background(), ri.env, RuntimeExecutionModeTournamentReset, nil, 0, "", "", "", "", "") ri.tournamentReset = func(ctx context.Context, tournament *api.Tournament, end, reset int64) error { ctx = NewRuntimeGoContext(ctx, ri.env, RuntimeExecutionModeTournamentReset, nil, 0, "", "", "", "", "") return fn(ctx, ri.logger, ri.db, ri.nk, tournament, end, reset) } return nil } func (ri *RuntimeGoInitializer) RegisterLeaderboardReset(fn func(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, leaderboard runtime.Leaderboard, reset int64) error) error { ri.leaderboardReset = func(leaderboard runtime.Leaderboard, reset int64) error { ctx := NewRuntimeGoContext(context.Background(), ri.env, RuntimeExecutionModeLeaderboardReset, nil, 0, "", "", "", "", "") ri.leaderboardReset = func(ctx context.Context, leaderboard runtime.Leaderboard, reset int64) error { ctx = NewRuntimeGoContext(ctx, ri.env, RuntimeExecutionModeLeaderboardReset, nil, 0, "", "", "", "", "") return fn(ctx, ri.logger, ri.db, ri.nk, leaderboard, reset) } return nil Loading Loading
CHANGELOG.md +1 −0 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - Check group max allowed user when promoting a user. - Correct Lua runtime decoding of stream identifying parameters. - Correctly use optional parameters when they are passed to group creation operations. - Lua runtime operations now observe context cancellation while waiting for an available Lua instance. ## [2.2.1] - 2018-11-20 ### Added Loading
server/leaderboard_scheduler.go +3 −3 Original line number Diff line number Diff line Loading @@ -277,7 +277,7 @@ WHERE id = $1` // Trigger callback on a goroutine so any extended processing does not block future scheduling. go func() { if err := fn(tournament, int64(tournament.EndActive), int64(tournament.NextReset)); err != nil { if err := fn(ls.ctx, tournament, int64(tournament.EndActive), int64(tournament.NextReset)); err != nil { ls.logger.Warn("Failed to invoke tournament end callback", zap.Error(err)) } }() Loading Loading @@ -327,7 +327,7 @@ WHERE id = $1` if fnTournamentReset != nil { // Trigger callback on a goroutine so any extended processing does not block future scheduling. go func() { if err := fnTournamentReset(tournament, int64(tournament.EndActive), int64(tournament.NextReset)); err != nil { if err := fnTournamentReset(ls.ctx, tournament, int64(tournament.EndActive), int64(tournament.NextReset)); err != nil { ls.logger.Warn("Failed to invoke tournament reset callback", zap.Error(err)) } }() Loading @@ -342,7 +342,7 @@ WHERE id = $1` // Trigger callback on a goroutine so any extended processing does not block future scheduling. go func() { if err := fnLeaderboardReset(leaderboardOrTournament, nextReset); err != nil { if err := fnLeaderboardReset(ls.ctx, leaderboardOrTournament, nextReset); err != nil { ls.logger.Warn("Failed to invoke leaderboard reset callback", zap.Error(err)) } }() Loading
server/pipeline_matchmaker.go +2 −1 Original line number Diff line number Diff line Loading @@ -15,6 +15,7 @@ package server import ( "context" "fmt" "time" Loading Loading @@ -79,7 +80,7 @@ func (p *Pipeline) matchmakerAdd(logger *zap.Logger, session Session, envelope * // Check if there's a matchmaker matched runtime callback, call it, and see if it returns a match ID. fn := p.runtime.MatchmakerMatched() if fn != nil { tokenOrMatchID, isMatchID, err = fn(entries) tokenOrMatchID, isMatchID, err = fn(context.Background(), entries) if err != nil { p.logger.Error("Error running Matchmaker Matched hook.", zap.Error(err)) } Loading
server/runtime.go +4 −4 Original line number Diff line number Diff line Loading @@ -161,15 +161,15 @@ type ( RuntimeBeforeGetUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, expiry int64, clientIP, clientPort string, in *api.GetUsersRequest) (*api.GetUsersRequest, error, codes.Code) RuntimeAfterGetUsersFunction func(ctx context.Context, logger *zap.Logger, userID, username string, expiry int64, clientIP, clientPort string, out *api.Users, in *api.GetUsersRequest) error RuntimeMatchmakerMatchedFunction func(entries []*MatchmakerEntry) (string, bool, error) RuntimeMatchmakerMatchedFunction func(ctx context.Context, entries []*MatchmakerEntry) (string, bool, error) RuntimeMatchCreateFunction func(ctx context.Context, logger *zap.Logger, id uuid.UUID, node string, name string) (RuntimeMatchCore, error) RuntimeMatchDeferMessageFunction func(msg *DeferredMessage) error RuntimeTournamentEndFunction func(tournament *api.Tournament, end, reset int64) error RuntimeTournamentResetFunction func(tournament *api.Tournament, end, reset int64) error RuntimeTournamentEndFunction func(ctx context.Context, tournament *api.Tournament, end, reset int64) error RuntimeTournamentResetFunction func(ctx context.Context, tournament *api.Tournament, end, reset int64) error RuntimeLeaderboardResetFunction func(leaderboard runtime.Leaderboard, reset int64) error RuntimeLeaderboardResetFunction func(ctx context.Context, leaderboard runtime.Leaderboard, reset int64) error ) type RuntimeExecutionMode int Loading
server/runtime_go.go +8 −8 Original line number Diff line number Diff line Loading @@ -1690,8 +1690,8 @@ func (ri *RuntimeGoInitializer) RegisterAfterGetUsers(fn func(ctx context.Contex } func (ri *RuntimeGoInitializer) RegisterMatchmakerMatched(fn func(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, entries []runtime.MatchmakerEntry) (string, error)) error { ri.matchmakerMatched = func(entries []*MatchmakerEntry) (string, bool, error) { ctx := NewRuntimeGoContext(context.Background(), ri.env, RuntimeExecutionModeMatchmaker, nil, 0, "", "", "", "", "") ri.matchmakerMatched = func(ctx context.Context, entries []*MatchmakerEntry) (string, bool, error) { ctx = NewRuntimeGoContext(ctx, ri.env, RuntimeExecutionModeMatchmaker, nil, 0, "", "", "", "", "") runtimeEntries := make([]runtime.MatchmakerEntry, len(entries)) for i, entry := range entries { runtimeEntries[i] = runtime.MatchmakerEntry(entry) Loading @@ -1706,24 +1706,24 @@ func (ri *RuntimeGoInitializer) RegisterMatchmakerMatched(fn func(ctx context.Co } func (ri *RuntimeGoInitializer) RegisterTournamentEnd(fn func(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, tournament *api.Tournament, end, reset int64) error) error { ri.tournamentEnd = func(tournament *api.Tournament, end, reset int64) error { ctx := NewRuntimeGoContext(context.Background(), ri.env, RuntimeExecutionModeTournamentEnd, nil, 0, "", "", "", "", "") ri.tournamentEnd = func(ctx context.Context, tournament *api.Tournament, end, reset int64) error { ctx = NewRuntimeGoContext(ctx, ri.env, RuntimeExecutionModeTournamentEnd, nil, 0, "", "", "", "", "") return fn(ctx, ri.logger, ri.db, ri.nk, tournament, end, reset) } return nil } func (ri *RuntimeGoInitializer) RegisterTournamentReset(fn func(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, tournament *api.Tournament, end, reset int64) error) error { ri.tournamentReset = func(tournament *api.Tournament, end, reset int64) error { ctx := NewRuntimeGoContext(context.Background(), ri.env, RuntimeExecutionModeTournamentReset, nil, 0, "", "", "", "", "") ri.tournamentReset = func(ctx context.Context, tournament *api.Tournament, end, reset int64) error { ctx = NewRuntimeGoContext(ctx, ri.env, RuntimeExecutionModeTournamentReset, nil, 0, "", "", "", "", "") return fn(ctx, ri.logger, ri.db, ri.nk, tournament, end, reset) } return nil } func (ri *RuntimeGoInitializer) RegisterLeaderboardReset(fn func(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, leaderboard runtime.Leaderboard, reset int64) error) error { ri.leaderboardReset = func(leaderboard runtime.Leaderboard, reset int64) error { ctx := NewRuntimeGoContext(context.Background(), ri.env, RuntimeExecutionModeLeaderboardReset, nil, 0, "", "", "", "", "") ri.leaderboardReset = func(ctx context.Context, leaderboard runtime.Leaderboard, reset int64) error { ctx = NewRuntimeGoContext(ctx, ri.env, RuntimeExecutionModeLeaderboardReset, nil, 0, "", "", "", "", "") return fn(ctx, ri.logger, ri.db, ri.nk, leaderboard, reset) } return nil Loading