diff --git a/server/core/region.go b/server/core/region.go index eb5b67b1a6e..7e449226c2b 100644 --- a/server/core/region.go +++ b/server/core/region.go @@ -58,6 +58,7 @@ type RegionInfo struct { replicationStatus *replication_modepb.RegionReplicationStatus QueryStats *pdpb.QueryStats flowRoundDivisor uint64 + buckets *metapb.Buckets } // NewRegionInfo creates RegionInfo with region's meta and leader peer. @@ -214,6 +215,11 @@ func (r *RegionInfo) Clone(opts ...RegionCreateOption) *RegionInfo { return region } +// GetBuckets returns the buckets of the region. +func (r *RegionInfo) GetBuckets() *metapb.Buckets { + return r.buckets +} + // GetTerm returns the current term of the region func (r *RegionInfo) GetTerm() uint64 { return r.term diff --git a/server/core/region_option.go b/server/core/region_option.go index fca63eb4992..f5a064a16c5 100644 --- a/server/core/region_option.go +++ b/server/core/region_option.go @@ -29,6 +29,13 @@ type RegionOption func(region *RegionInfo) bool // RegionCreateOption used to create region. type RegionCreateOption func(region *RegionInfo) +// WithBuckets sets the buckets for the region. +func WithBuckets(buckets *metapb.Buckets) RegionCreateOption { + return func(region *RegionInfo) { + region.buckets = buckets + } +} + // WithDownPeers sets the down peers for the region. func WithDownPeers(downPeers []*pdpb.PeerStats) RegionCreateOption { return func(region *RegionInfo) {