Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: add buckets property to regionInfo struct #4743

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions server/core/region.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions server/core/region_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down