aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/game/hub.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-08 20:00:06 +0900
committernsfisis <nsfisis@gmail.com>2024-08-08 20:00:06 +0900
commitef1577a212d1b5c6f908a59b943a512d33d312fe (patch)
tree7c91a689aaea376985ec579d71c1169fdc2ee47a /backend/game/hub.go
parent205cb5e21b960852a06fa28baaa03dbbd6aa835f (diff)
downloadiosdc-japan-2024-albatross-ef1577a212d1b5c6f908a59b943a512d33d312fe.tar.gz
iosdc-japan-2024-albatross-ef1577a212d1b5c6f908a59b943a512d33d312fe.tar.zst
iosdc-japan-2024-albatross-ef1577a212d1b5c6f908a59b943a512d33d312fe.zip
feat(backend/worker): enable `revive` in `golangci-lint`
Diffstat (limited to 'backend/game/hub.go')
-rw-r--r--backend/game/hub.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/backend/game/hub.go b/backend/game/hub.go
index 11a466b..dc56f03 100644
--- a/backend/game/hub.go
+++ b/backend/game/hub.go
@@ -544,15 +544,15 @@ func (hub *gameHub) closeWatcherClient(watcher *watcherClient) {
close(watcher.s2cMessages)
}
-type GameHubs struct {
+type Hubs struct {
hubs map[int]*gameHub
q *db.Queries
taskQueue *taskqueue.Queue
taskResults chan taskqueue.TaskResult
}
-func NewGameHubs(q *db.Queries, taskQueue *taskqueue.Queue, taskResults chan taskqueue.TaskResult) *GameHubs {
- return &GameHubs{
+func NewGameHubs(q *db.Queries, taskQueue *taskqueue.Queue, taskResults chan taskqueue.TaskResult) *Hubs {
+ return &Hubs{
hubs: make(map[int]*gameHub),
q: q,
taskQueue: taskQueue,
@@ -560,18 +560,18 @@ func NewGameHubs(q *db.Queries, taskQueue *taskqueue.Queue, taskResults chan tas
}
}
-func (hubs *GameHubs) Close() {
+func (hubs *Hubs) Close() {
log.Println("closing all game hubs")
for _, hub := range hubs.hubs {
hub.close()
}
}
-func (hubs *GameHubs) getHub(gameID int) *gameHub {
+func (hubs *Hubs) getHub(gameID int) *gameHub {
return hubs.hubs[gameID]
}
-func (hubs *GameHubs) RestoreFromDB(ctx context.Context) error {
+func (hubs *Hubs) RestoreFromDB(ctx context.Context) error {
games, err := hubs.q.ListGames(ctx)
if err != nil {
return err
@@ -581,12 +581,12 @@ func (hubs *GameHubs) RestoreFromDB(ctx context.Context) error {
if row.StartedAt.Valid {
startedAt = &row.StartedAt.Time
}
- var problem_ *problem
+ var pr *problem
if row.ProblemID != nil {
if row.Title == nil || row.Description == nil {
panic("inconsistent data")
}
- problem_ = &problem{
+ pr = &problem{
problemID: int(*row.ProblemID),
title: *row.Title,
description: *row.Description,
@@ -603,14 +603,14 @@ func (hubs *GameHubs) RestoreFromDB(ctx context.Context) error {
state: gameState(row.State),
displayName: row.DisplayName,
startedAt: startedAt,
- problem: problem_,
+ problem: pr,
playerCount: len(playerRows),
}, hubs.q, hubs.taskQueue)
}
return nil
}
-func (hubs *GameHubs) Run() {
+func (hubs *Hubs) Run() {
for _, hub := range hubs.hubs {
go hub.run()
go hub.processTaskResults()
@@ -626,11 +626,11 @@ func (hubs *GameHubs) Run() {
}
}
-func (hubs *GameHubs) SockHandler() *sockHandler {
+func (hubs *Hubs) SockHandler() *SockHandler {
return newSockHandler(hubs)
}
-func (hubs *GameHubs) StartGame(gameID int) error {
+func (hubs *Hubs) StartGame(gameID int) error {
hub := hubs.getHub(gameID)
if hub == nil {
return errors.New("no such game")