v0.13.0 web and terminal client enhance, replay api, linux server deploy, doc and dependency update
test / test (push) Canceled after 0s
test / test (push) Canceled after 0s
This commit is contained in:
1 parent
52ac0fe31a
commit
f1ac4cbbe7
71 files changed
+7677
-537
No files matched your search
@@ -68,6 +68,15 @@ type Store struct {
|
||||
enqueueMu sync.RWMutex
|
||||
closeOnce sync.Once
|
||||
closeErr error
|
||||
gameMissing atomic.Pointer[func(gameID string)]
|
||||
}
|
||||
|
||||
// SetGameMissingHandler registers the callback run, on its own goroutine,
|
||||
// when a write finds its game row gone. Such a write is dropped without
|
||||
// degrading storage: later writes for that game fail the same way and write
|
||||
// nothing, so no other game's history is affected.
|
||||
func (s *Store) SetGameMissingHandler(handler func(gameID string)) {
|
||||
s.gameMissing.Store(&handler)
|
||||
}
|
||||
|
||||
// NewStore connects to PostgreSQL and starts the async writer. dsn is a
|
||||
@@ -203,6 +212,14 @@ func (s *Store) executeWrite(req writeRequest) error {
|
||||
)
|
||||
return nil
|
||||
}
|
||||
if errors.Is(err, ErrGameMissing) {
|
||||
slog.Warn("storage write dropped: game row no longer exists",
|
||||
"operation", req.operation, "game_id", req.gameID)
|
||||
if handler := s.gameMissing.Load(); handler != nil && req.gameID != "" {
|
||||
go (*handler)(req.gameID)
|
||||
}
|
||||
return err
|
||||
}
|
||||
if committing || attempt >= writeAttempts || !isTransient(err) {
|
||||
break
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user