From 3183b9ebb3408fb2ecedeb6c03349118af5a025c Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 2 Oct 2020 13:55:41 -0400 Subject: [PATCH] subscribe: update to use NewSnapshotToFollow event --- agent/rpc/subscribe/auth.go | 2 +- agent/rpc/subscribe/logger.go | 5 +++-- agent/rpc/subscribe/subscribe.go | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/agent/rpc/subscribe/auth.go b/agent/rpc/subscribe/auth.go index 81ee3e934..094ed4e3b 100644 --- a/agent/rpc/subscribe/auth.go +++ b/agent/rpc/subscribe/auth.go @@ -10,7 +10,7 @@ import ( // event is allowed to be sent to this client or not. func enforceACL(authz acl.Authorizer, e stream.Event) acl.EnforcementDecision { switch { - case e.IsEndOfSnapshot(), e.IsEndOfEmptySnapshot(): + case e.IsEndOfSnapshot(), e.IsNewSnapshotToFollow(): return acl.Allow } diff --git a/agent/rpc/subscribe/logger.go b/agent/rpc/subscribe/logger.go index b1a32a6cd..9aadf6a40 100644 --- a/agent/rpc/subscribe/logger.go +++ b/agent/rpc/subscribe/logger.go @@ -59,10 +59,11 @@ func (l *eventLogger) Trace(e []stream.Event) { first := e[0] switch { - case first.IsEndOfSnapshot() || first.IsEndOfEmptySnapshot(): + case first.IsEndOfSnapshot(): l.snapshotDone = true l.logger.Trace("snapshot complete", "index", first.Index, "sent", l.count) - + case first.IsNewSnapshotToFollow(): + return case l.snapshotDone: l.logger.Trace("sending events", "index", first.Index, "sent", l.count, "batch_size", len(e)) } diff --git a/agent/rpc/subscribe/subscribe.go b/agent/rpc/subscribe/subscribe.go index 191638f29..981c1714b 100644 --- a/agent/rpc/subscribe/subscribe.go +++ b/agent/rpc/subscribe/subscribe.go @@ -169,8 +169,8 @@ func newEventFromStreamEvents(req *pbsubscribe.SubscribeRequest, events []stream case event.IsEndOfSnapshot(): e.Payload = &pbsubscribe.Event_EndOfSnapshot{EndOfSnapshot: true} return e - case event.IsEndOfEmptySnapshot(): - e.Payload = &pbsubscribe.Event_EndOfEmptySnapshot{EndOfEmptySnapshot: true} + case event.IsNewSnapshotToFollow(): + e.Payload = &pbsubscribe.Event_NewSnapshotToFollow{NewSnapshotToFollow: true} return e }