Browse Source

submatview: remove notifyUpdateLocked from reset

This call appears to only be necessary because reset() was called from
NewMaterializer.

This commit has the constructor set a default value for updateCh, and
removes both the call to reset() from New(), and the call to
notifyUpdateLocked() from reset().

This should ensure that we do not notify the Fetch() call before we have new
values to report.
pull/8809/head
Daniel Nephin 4 years ago
parent
commit
d0b87cd5d0
  1. 11
      agent/submatview/materializer.go

11
agent/submatview/materializer.go

@ -78,8 +78,8 @@ func NewMaterializer(deps Deps) *Materializer {
deps: deps, deps: deps,
view: deps.View, view: deps.View,
retryWaiter: deps.Waiter, retryWaiter: deps.Waiter,
updateCh: make(chan struct{}),
} }
v.reset()
return v return v
} }
@ -112,8 +112,8 @@ func (m *Materializer) Run(ctx context.Context) {
} }
} }
// isNonTemporaryOrConsecutiveFailure returns true if the error is a temporary error // isNonTemporaryOrConsecutiveFailure returns true if the error is not a
// or if the failures > 0. // temporary error or if failures > 0.
func isNonTemporaryOrConsecutiveFailure(err error, failures int) bool { func isNonTemporaryOrConsecutiveFailure(err error, failures int) bool {
// temporary is an interface used by net and other std lib packages to // temporary is an interface used by net and other std lib packages to
// show error types represent temporary/recoverable errors. // show error types represent temporary/recoverable errors.
@ -181,7 +181,6 @@ func (m *Materializer) reset() {
m.view.Reset() m.view.Reset()
m.index = 0 m.index = 0
m.notifyUpdateLocked(nil)
m.retryWaiter.Reset() m.retryWaiter.Reset()
} }
@ -202,9 +201,7 @@ func (m *Materializer) updateView(events []*pbsubscribe.Event, index uint64) err
// one. It must be called while holding the s.lock lock. // one. It must be called while holding the s.lock lock.
func (m *Materializer) notifyUpdateLocked(err error) { func (m *Materializer) notifyUpdateLocked(err error) {
m.err = err m.err = err
if m.updateCh != nil { close(m.updateCh)
close(m.updateCh)
}
m.updateCh = make(chan struct{}) m.updateCh = make(chan struct{})
} }

Loading…
Cancel
Save