refactor: 重构集群主从节点模式

This commit is contained in:
tbphp
2025-07-15 10:25:55 +08:00
parent ee400afbcd
commit fc63189246
12 changed files with 58 additions and 363 deletions

View File

@@ -70,6 +70,7 @@ func (m *Manager) ReloadConfig() error {
config := &Config{
Server: types.ServerConfig{
IsMaster: !utils.ParseBoolean(os.Getenv("IS_SLAVE"), true),
Port: utils.ParseInteger(os.Getenv("PORT"), 3001),
Host: utils.GetEnvOrDefault("HOST", "0.0.0.0"),
ReadTimeout: utils.ParseInteger(os.Getenv("SERVER_READ_TIMEOUT"), 120),
@@ -111,6 +112,11 @@ func (m *Manager) ReloadConfig() error {
return nil
}
// IsMaster returns Server mode
func (m *Manager) IsMaster() bool {
return m.config.Server.IsMaster
}
// GetAuthConfig returns authentication configuration
func (m *Manager) GetAuthConfig() types.AuthConfig {
return m.config.Auth