From 7961fbc1374e6ae2f92fdf95587c4c80273b16d9 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 6 Apr 2020 18:33:26 +0200 Subject: [PATCH] Remove RingConsumer.Close This is now unused. --- ring.go | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/ring.go b/ring.go index aae96d8..9656b2a 100644 --- a/ring.go +++ b/ring.go @@ -70,9 +70,8 @@ func (r *Ring) NewConsumer(seq *uint64) *RingConsumer { // RingConsumer is a ring buffer consumer. type RingConsumer struct { - ring *Ring - cur uint64 - closed bool + ring *Ring + cur uint64 } // diff returns the number of pending messages. It assumes the Ring is locked. @@ -86,10 +85,6 @@ func (rc *RingConsumer) diff() uint64 { // Peek returns the next pending message if any without consuming it. A nil // message is returned if no message is available. func (rc *RingConsumer) Peek() *irc.Message { - if rc.closed { - panic("soju: RingConsumer.Peek called after Close") - } - diff := rc.diff() if diff == 0 { return nil @@ -115,18 +110,3 @@ func (rc *RingConsumer) Consume() *irc.Message { } return msg } - -// Close stops consuming messages. The consumer channel will be closed. The -// current history sequence number is returned. It can be provided later as an -// argument to Ring.NewConsumer to resume the message stream. -func (rc *RingConsumer) Close() uint64 { - for i := range rc.ring.consumers { - if rc.ring.consumers[i] == rc { - rc.ring.consumers = append(rc.ring.consumers[:i], rc.ring.consumers[i+1:]...) - break - } - } - - rc.closed = true - return rc.cur -}