feat: runtime manager
This commit is contained in:
@@ -54,6 +54,11 @@ const (
|
||||
// gateway self-service delegation.
|
||||
userServiceBaseURLEnvVar = "GATEWAY_USER_SERVICE_BASE_URL"
|
||||
|
||||
// lobbyServiceBaseURLEnvVar names the environment variable that configures
|
||||
// the optional Game Lobby public HTTP base URL used by authenticated
|
||||
// gateway platform-command delegation.
|
||||
lobbyServiceBaseURLEnvVar = "GATEWAY_LOBBY_SERVICE_BASE_URL"
|
||||
|
||||
// adminHTTPAddrEnvVar names the environment variable that configures the
|
||||
// private admin HTTP listener address. When it is empty, the admin listener
|
||||
// remains disabled.
|
||||
@@ -475,6 +480,15 @@ type UserServiceConfig struct {
|
||||
BaseURL string
|
||||
}
|
||||
|
||||
// LobbyServiceConfig describes the optional authenticated platform-command
|
||||
// upstream used by the gateway runtime.
|
||||
type LobbyServiceConfig struct {
|
||||
// BaseURL is the absolute base URL of the Game Lobby public HTTP API.
|
||||
// When BaseURL is empty, the gateway keeps using its built-in unavailable
|
||||
// downstream adapter for the reserved `lobby.*` routes.
|
||||
BaseURL string
|
||||
}
|
||||
|
||||
// AdminHTTPConfig describes the private operational HTTP listener used for
|
||||
// metrics exposure. The listener remains disabled when Addr is empty.
|
||||
type AdminHTTPConfig struct {
|
||||
@@ -597,6 +611,10 @@ type Config struct {
|
||||
// delegation to User Service.
|
||||
UserService UserServiceConfig
|
||||
|
||||
// LobbyService configures the optional authenticated platform-command
|
||||
// delegation to Game Lobby.
|
||||
LobbyService LobbyServiceConfig
|
||||
|
||||
// AdminHTTP configures the optional private admin listener used for metrics
|
||||
// exposure.
|
||||
AdminHTTP AdminHTTPConfig
|
||||
@@ -788,6 +806,13 @@ func DefaultUserServiceConfig() UserServiceConfig {
|
||||
return UserServiceConfig{}
|
||||
}
|
||||
|
||||
// DefaultLobbyServiceConfig returns the default authenticated platform-command
|
||||
// upstream settings. The zero value keeps the built-in unavailable adapter
|
||||
// active for reserved `lobby.*` routes.
|
||||
func DefaultLobbyServiceConfig() LobbyServiceConfig {
|
||||
return LobbyServiceConfig{}
|
||||
}
|
||||
|
||||
// LoadFromEnv loads Config from the process environment, applies defaults for
|
||||
// omitted settings, and validates the resulting values.
|
||||
func LoadFromEnv() (Config, error) {
|
||||
@@ -797,6 +822,7 @@ func LoadFromEnv() (Config, error) {
|
||||
PublicHTTP: DefaultPublicHTTPConfig(),
|
||||
AuthService: DefaultAuthServiceConfig(),
|
||||
UserService: DefaultUserServiceConfig(),
|
||||
LobbyService: DefaultLobbyServiceConfig(),
|
||||
AdminHTTP: DefaultAdminHTTPConfig(),
|
||||
AuthenticatedGRPC: DefaultAuthenticatedGRPCConfig(),
|
||||
Redis: redisconn.DefaultConfig(),
|
||||
@@ -860,6 +886,11 @@ func LoadFromEnv() (Config, error) {
|
||||
cfg.UserService.BaseURL = rawUserServiceBaseURL
|
||||
}
|
||||
|
||||
rawLobbyServiceBaseURL, ok := os.LookupEnv(lobbyServiceBaseURLEnvVar)
|
||||
if ok {
|
||||
cfg.LobbyService.BaseURL = rawLobbyServiceBaseURL
|
||||
}
|
||||
|
||||
rawAdminHTTPAddr, ok := os.LookupEnv(adminHTTPAddrEnvVar)
|
||||
if ok {
|
||||
cfg.AdminHTTP.Addr = rawAdminHTTPAddr
|
||||
|
||||
Reference in New Issue
Block a user