Remove RingConsumer.Close

This is now unused.
This commit is contained in:
Simon Ser 2020-04-06 18:33:26 +02:00
parent f0bc919885
commit 7961fbc137
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

20
ring.go
View File

@ -72,7 +72,6 @@ func (r *Ring) NewConsumer(seq *uint64) *RingConsumer {
type RingConsumer struct {
ring *Ring
cur uint64
closed bool
}
// 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
}