Skip to content

Commit

Permalink
fix rpo empty
Browse files Browse the repository at this point in the history
Signed-off-by: iosmanthus <[email protected]>
  • Loading branch information
iosmanthus committed Nov 26, 2021
1 parent be48433 commit 711e09e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions common/region_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ type RegionState struct {
}

type Aggregator interface {
Get() *RegionInfos
Merge(b *RegionInfos)
}

Expand All @@ -86,7 +87,6 @@ func NewRegionCollector() Collector {
func (f *RegionCollector) Collect(ctx context.Context, fetchers []Fetcher, m Aggregator) (*RegionInfos, error) {
ch := make(chan Result, len(fetchers))

infos := NewRegionInfos()
for _, fetcher := range fetchers {
go func(fetcher Fetcher) {
ctx, cancel := context.WithTimeout(ctx, time.Minute*1)
Expand All @@ -109,5 +109,5 @@ func (f *RegionCollector) Collect(ctx context.Context, fetchers []Fetcher, m Agg
m.Merge(result.RegionInfos)
}

return infos, nil
return m.Get(), nil
}
4 changes: 4 additions & 0 deletions components/recover/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ func NewResolver() *Resolver {
}
}

func (r *Resolver) Get() *common.RegionInfos {
return nil
}

func (r *Resolver) Merge(b *common.RegionInfos) {
for _, state := range b.StateMap {
r.buffer = append(r.buffer, state)
Expand Down
4 changes: 4 additions & 0 deletions components/rpo/rpo.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func NewMaxApplyIndex() *MaxApplyIndex {
}
}

func (m *MaxApplyIndex) Get() *common.RegionInfos {
return m.inner
}

func (m *MaxApplyIndex) Merge(b *common.RegionInfos) {
inner := m.inner
for id, info := range b.StateMap {
Expand Down

0 comments on commit 711e09e

Please sign in to comment.