Skip to content

Commit

Permalink
Unify the TSO ServiceConfig and ConfigProvider interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: JmPotato <ghzpotato@gmail.com>
  • Loading branch information
JmPotato committed Apr 6, 2023
1 parent 33daef0 commit fff67a0
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 TSOConfig,
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
TSOConfig
}

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

0 comments on commit fff67a0

Please sign in to comment.