mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-27 01:53:19 +01:00
refactor: replace raw SQL with repository interfaces in entranceserver and API server
Extract all direct database calls from entranceserver (2 calls) and API server (17 calls) into typed repository interfaces with PostgreSQL implementations, matching the pattern established in signserver and channelserver. Entranceserver: EntranceServerRepo, EntranceSessionRepo API server: APIUserRepo, APICharacterRepo, APISessionRepo Also fix the 3 remaining fmt.Sprintf calls inside logger invocations in handlers_commands.go and handlers_stage.go, replacing them with structured zap fields. Unskip 5 TestNewAuthData* tests that previously required a real database — they now run with mock repos.
This commit is contained in:
19
server/entranceserver/repo_interfaces.go
Normal file
19
server/entranceserver/repo_interfaces.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package entranceserver
|
||||
|
||||
// Repository interfaces decouple entrance server business logic from concrete
|
||||
// PostgreSQL implementations, enabling mock/stub injection for unit tests.
|
||||
|
||||
// EntranceServerRepo defines the contract for server-related data access
|
||||
// used by the entrance server when building server list responses.
|
||||
type EntranceServerRepo interface {
|
||||
// GetCurrentPlayers returns the current player count for a given server ID.
|
||||
GetCurrentPlayers(serverID int) (uint16, error)
|
||||
}
|
||||
|
||||
// EntranceSessionRepo defines the contract for session-related data access
|
||||
// used by the entrance server when resolving user locations.
|
||||
type EntranceSessionRepo interface {
|
||||
// GetServerIDForCharacter returns the server ID where the given character
|
||||
// is currently signed in, or 0 if not found.
|
||||
GetServerIDForCharacter(charID uint32) (uint16, error)
|
||||
}
|
||||
Reference in New Issue
Block a user