package system_setting

import "github.com/QuantumNous/new-api/setting/config"

// RegionSyncSettings 跨地区同步配置
type RegionSyncSettings struct {
	Enabled        bool     `json:"enabled"`
	RegionId       string   `json:"region_id"`
	IsMaster       bool     `json:"is_master"`
	MasterEndpoint string   `json:"master_endpoint"`
	SlaveEndpoints []string `json:"slave_endpoints"`
	SyncApiKey     string   `json:"sync_api_key"`

	MinBalanceThreshold int `json:"min_balance_threshold"`
	SyncIntervalSeconds int `json:"sync_interval_seconds"`
	MaxRetryCount       int `json:"max_retry_count"`
	SyncBatchSize       int `json:"sync_batch_size"`

	QuotaSyncIntervalSeconds int  `json:"quota_sync_interval_seconds"` // 余额同步间隔（秒）
	DisableCachedConsume     bool `json:"disable_cached_consume"`
}

var defaultRegionSyncSettings = RegionSyncSettings{
	Enabled:                  false,
	MinBalanceThreshold:      100000,
	SyncIntervalSeconds:      60,
	MaxRetryCount:            3,
	SyncBatchSize:            100,
	QuotaSyncIntervalSeconds: 300,
}

func init() {
	config.GlobalConfig.Register("region_sync", &defaultRegionSyncSettings)
}

func GetRegionSyncSettings() *RegionSyncSettings {
	return &defaultRegionSyncSettings
}
