Skip to content

Commit

Permalink
debug(remove): log rooms being removed after sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
hspedro committed Aug 21, 2024
1 parent f0608a5 commit 359f2d2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions internal/core/operations/rooms/remove/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/topfreegames/maestro/internal/core/ports"
porterrors "github.com/topfreegames/maestro/internal/core/ports/errors"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"golang.org/x/sync/errgroup"
)

Expand Down Expand Up @@ -121,6 +122,8 @@ func (e *Executor) removeRoomsByAmount(ctx context.Context, logger *zap.Logger,
} else {
var activeVersionRooms []*game_room.GameRoom
var mostPrioRoomsToBeRemoved []*game_room.GameRoom
originalRoomsOrder := make([]*game_room.GameRoom, len(rooms))
copy(originalRoomsOrder, rooms)
for _, room := range rooms {
if room.Status == game_room.GameStatusOccupied || room.Status == game_room.GameStatusReady || room.Status == game_room.GameStatusPending {
if room.Version == activeScheduler.Spec.Version {
Expand All @@ -133,6 +136,20 @@ func (e *Executor) removeRoomsByAmount(ctx context.Context, logger *zap.Logger,
}
}
rooms = append(mostPrioRoomsToBeRemoved, activeVersionRooms...)
logger.Info("removing rooms by amount sorting by version",
zap.Array("originalRoomsOrder", zapcore.ArrayMarshalerFunc(func(enc zapcore.ArrayEncoder) error {
for _, room := range originalRoomsOrder {
enc.AppendString(fmt.Sprintf("%s-%s-%s", room.ID, room.Version, room.Status.String()))
}
return nil
})),
zap.Array("newRoomsOrder", zapcore.ArrayMarshalerFunc(func(enc zapcore.ArrayEncoder) error {
for _, room := range rooms {
enc.AppendString(fmt.Sprintf("%s-%s-%s", room.ID, room.Version, room.Status.String()))
}
return nil
})),
)
}

err = e.deleteRooms(ctx, rooms, op, reason)
Expand Down

0 comments on commit 359f2d2

Please sign in to comment.