Remove RingConsumer.Close
This is now unused.
This commit is contained in:
parent
f0bc919885
commit
7961fbc137
20
ring.go
20
ring.go
@ -72,7 +72,6 @@ func (r *Ring) NewConsumer(seq *uint64) *RingConsumer {
|
|||||||
type RingConsumer struct {
|
type RingConsumer struct {
|
||||||
ring *Ring
|
ring *Ring
|
||||||
cur uint64
|
cur uint64
|
||||||
closed bool
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// diff returns the number of pending messages. It assumes the Ring is locked.
|
// 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
|
// Peek returns the next pending message if any without consuming it. A nil
|
||||||
// message is returned if no message is available.
|
// message is returned if no message is available.
|
||||||
func (rc *RingConsumer) Peek() *irc.Message {
|
func (rc *RingConsumer) Peek() *irc.Message {
|
||||||
if rc.closed {
|
|
||||||
panic("soju: RingConsumer.Peek called after Close")
|
|
||||||
}
|
|
||||||
|
|
||||||
diff := rc.diff()
|
diff := rc.diff()
|
||||||
if diff == 0 {
|
if diff == 0 {
|
||||||
return nil
|
return nil
|
||||||
@ -115,18 +110,3 @@ func (rc *RingConsumer) Consume() *irc.Message {
|
|||||||
}
|
}
|
||||||
return msg
|
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
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user