diff --git a/agent/consul/stream/event_buffer.go b/agent/consul/stream/event_buffer.go index 830b302347..f8a037e349 100644 --- a/agent/consul/stream/event_buffer.go +++ b/agent/consul/stream/event_buffer.go @@ -33,7 +33,7 @@ import ( // the first event in the buffer, we can cache the buffered events for future // watchers on the same topic. Finally, once we've delivered all the snapshot // events to the buffer, we can append a next-element which is the first topic -// buffer element with a higher index and so consumers can just keep reading the +// buffer element with a higher index and so consumers can keep reading the // same buffer. // // A huge benefit here is that caching snapshots becomes very simple - we don't @@ -124,9 +124,8 @@ func (b *EventBuffer) Head() *BufferItem { } // BufferItem represents a set of events published by a single raft operation. -// The first item returned by a newly constructed buffer will have nil Events -// and should be considered a "sentinel" value just useful for waiting on the -// next events via Next. +// The first item returned by a newly constructed buffer will have nil Events. +// It is a sentinel value which is used to wait on the next events via Next. // // To iterate to the next event, a Next method may be called which may block if // there is no next element yet. diff --git a/agent/consul/stream/event_buffer_test.go b/agent/consul/stream/event_buffer_test.go index eadd638160..cd2461c778 100644 --- a/agent/consul/stream/event_buffer_test.go +++ b/agent/consul/stream/event_buffer_test.go @@ -26,10 +26,12 @@ func TestEventBufferFuzz(t *testing.T) { // indexes and some jitter in timing (to allow clients to "catch up" and block // waiting for updates). go func() { + seed := time.Now().UnixNano() + t.Logf("Using seed %d", seed) // z is a Zipfian distribution that gives us a number of milliseconds to // sleep which are mostly low - near zero but occasionally spike up to near // 100. - z := rand.NewZipf(rand.New(rand.NewSource(1)), 1.5, 1.5, 50) + z := rand.NewZipf(rand.New(rand.NewSource(seed)), 1.5, 1.5, 50) for i := 0; i < nMessages; i++ { // Event content is arbitrary and not valid for our use of buffers in