From 711e09e16ee604dd80048b0c30da3f27c3692f13 Mon Sep 17 00:00:00 2001 From: iosmanthus Date: Fri, 26 Nov 2021 21:25:31 +0800 Subject: [PATCH] fix rpo empty Signed-off-by: iosmanthus --- common/region_info.go | 4 ++-- components/recover/resolver.go | 4 ++++ components/rpo/rpo.go | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/region_info.go b/common/region_info.go index 6ea70a4..440d380 100644 --- a/common/region_info.go +++ b/common/region_info.go @@ -66,6 +66,7 @@ type RegionState struct { } type Aggregator interface { + Get() *RegionInfos Merge(b *RegionInfos) } @@ -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) @@ -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 } diff --git a/components/recover/resolver.go b/components/recover/resolver.go index df765c9..c5d98b9 100644 --- a/components/recover/resolver.go +++ b/components/recover/resolver.go @@ -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) diff --git a/components/rpo/rpo.go b/components/rpo/rpo.go index 9a9c0a0..b34bdfa 100644 --- a/components/rpo/rpo.go +++ b/components/rpo/rpo.go @@ -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 {