Make Ring.NewConsumer seq argument mandatory
There's no point in supporting a nil argument anymore.
This commit is contained in:
parent
7ce369958e
commit
dd08acc3ea
@ -661,15 +661,12 @@ func (dc *downstreamConn) welcome() error {
|
||||
})
|
||||
|
||||
dc.forEachNetwork(func(net *network) {
|
||||
var seqPtr *uint64
|
||||
if sendHistory {
|
||||
seq, ok := net.history[dc.clientName]
|
||||
if ok {
|
||||
seqPtr = &seq
|
||||
}
|
||||
seq, ok := net.history[dc.clientName]
|
||||
if !sendHistory || !ok {
|
||||
return
|
||||
}
|
||||
|
||||
consumer := net.ring.NewConsumer(seqPtr)
|
||||
consumer := net.ring.NewConsumer(seq)
|
||||
|
||||
// TODO: this means all history is lost when trying to send it while the
|
||||
// upstream is disconnected. We need to store history differently so that
|
||||
|
19
ring.go
19
ring.go
@ -31,27 +31,18 @@ func (r *Ring) Produce(msg *irc.Message) {
|
||||
r.cur++
|
||||
}
|
||||
|
||||
// Cur returns the current history sequence number.
|
||||
func (r *Ring) Cur() uint64 {
|
||||
return r.cur
|
||||
}
|
||||
|
||||
// NewConsumer creates a new ring buffer consumer.
|
||||
//
|
||||
// If seq is nil, the consumer will get messages starting from the last
|
||||
// producer message. If seq is non-nil, the consumer will get messages starting
|
||||
// from the specified history sequence number (see RingConsumer.Close).
|
||||
//
|
||||
// The consumer can only be used from a single goroutine.
|
||||
func (r *Ring) NewConsumer(seq *uint64) *RingConsumer {
|
||||
consumer := &RingConsumer{ring: r}
|
||||
|
||||
if seq != nil {
|
||||
consumer.cur = *seq
|
||||
} else {
|
||||
consumer.cur = r.cur
|
||||
}
|
||||
// The consumer will get messages starting from the specified history sequence
|
||||
// number (see Ring.Cur).
|
||||
func (r *Ring) NewConsumer(seq uint64) *RingConsumer {
|
||||
consumer := &RingConsumer{ring: r, cur: seq}
|
||||
r.consumers = append(r.consumers, consumer)
|
||||
|
||||
return consumer
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user