Skip to content

Commit

Permalink
tso: unify the TSO ServiceConfig and ConfigProvider interfaces (#6272)
Browse files Browse the repository at this point in the history
ref #5895

Unify the TSO `ServiceConfig` and `ConfigProvider` interfaces.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato authored Apr 6, 2023
1 parent 33daef0 commit 9aa3e97
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
24 changes: 7 additions & 17 deletions pkg/tso/allocator_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,6 @@ type ElectionMember interface {
PrecheckLeader() error
}

// ConfigProvider is used to provide TSO configuration.
type ConfigProvider interface {
IsLocalTSOEnabled() bool
GetLeaderLease() int64
GetTSOSaveInterval() time.Duration
GetTSOUpdatePhysicalInterval() time.Duration
GetMaxResetTSGap() time.Duration
GetTLSConfig() *grpcutil.TLSConfig
}

// AllocatorManager is used to manage the TSO Allocators a PD server holds.
// It is in charge of maintaining TSO allocators' leadership, checking election
// priority, and forwarding TSO allocation requests to correct TSO Allocators.
Expand Down Expand Up @@ -207,7 +197,7 @@ func NewAllocatorManager(
member ElectionMember,
rootPath string,
storage endpoint.TSOStorage,
configProvider ConfigProvider,
cfg Config,
startGlobalLeaderLoop bool,
) *AllocatorManager {
ctx, cancel := context.WithCancel(ctx)
Expand All @@ -218,12 +208,12 @@ func NewAllocatorManager(
member: member,
rootPath: rootPath,
storage: storage,
enableLocalTSO: configProvider.IsLocalTSOEnabled(),
saveInterval: configProvider.GetTSOSaveInterval(),
updatePhysicalInterval: configProvider.GetTSOUpdatePhysicalInterval(),
leaderLease: configProvider.GetLeaderLease(),
maxResetTSGap: configProvider.GetMaxResetTSGap,
securityConfig: configProvider.GetTLSConfig(),
enableLocalTSO: cfg.IsLocalTSOEnabled(),
saveInterval: cfg.GetTSOSaveInterval(),
updatePhysicalInterval: cfg.GetTSOUpdatePhysicalInterval(),
leaderLease: cfg.GetLeaderLease(),
maxResetTSGap: cfg.GetMaxResetTSGap,
securityConfig: cfg.GetTLSConfig(),
}
am.mu.allocatorGroups = make(map[string]*allocatorGroup)
am.mu.clusterDCLocations = make(map[string]*DCLocationInfo)
Expand Down
6 changes: 6 additions & 0 deletions pkg/tso/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ type ServiceConfig interface {
GetListenAddr() string
// GetAdvertiseListenAddr returns the AdvertiseListenAddr
GetAdvertiseListenAddr() string
// TSO-related configuration
Config
}

// Config is used to provide TSO configuration.
type Config interface {
// GetLeaderLease returns the leader lease.
GetLeaderLease() int64
// IsLocalTSOEnabled returns if the local TSO is enabled.
Expand Down

0 comments on commit 9aa3e97

Please sign in to comment.