Changeset 242 in code


Ignore:
Timestamp:
Apr 7, 2020, 12:45:08 PM (5 years ago)
Author:
contact
Message:

Make Ring.NewConsumer seq argument mandatory

There's no point in supporting a nil argument anymore.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r239 r242  
    662662
    663663        dc.forEachNetwork(func(net *network) {
    664                 var seqPtr *uint64
    665                 if sendHistory {
    666                         seq, ok := net.history[dc.clientName]
    667                         if ok {
    668                                 seqPtr = &seq
    669                         }
    670                 }
    671 
    672                 consumer := net.ring.NewConsumer(seqPtr)
     664                seq, ok := net.history[dc.clientName]
     665                if !sendHistory || !ok {
     666                        return
     667                }
     668
     669                consumer := net.ring.NewConsumer(seq)
    673670
    674671                // TODO: this means all history is lost when trying to send it while the
  • trunk/ring.go

    r241 r242  
    3232}
    3333
     34// Cur returns the current history sequence number.
    3435func (r *Ring) Cur() uint64 {
    3536        return r.cur
     
    3839// NewConsumer creates a new ring buffer consumer.
    3940//
    40 // If seq is nil, the consumer will get messages starting from the last
    41 // producer message. If seq is non-nil, the consumer will get messages starting
    42 // from the specified history sequence number (see RingConsumer.Close).
    43 //
    44 // The consumer can only be used from a single goroutine.
    45 func (r *Ring) NewConsumer(seq *uint64) *RingConsumer {
    46         consumer := &RingConsumer{ring: r}
    47 
    48         if seq != nil {
    49                 consumer.cur = *seq
    50         } else {
    51                 consumer.cur = r.cur
    52         }
     41// The consumer will get messages starting from the specified history sequence
     42// number (see Ring.Cur).
     43func (r *Ring) NewConsumer(seq uint64) *RingConsumer {
     44        consumer := &RingConsumer{ring: r, cur: seq}
    5345        r.consumers = append(r.consumers, consumer)
    54 
    5546        return consumer
    5647}
Note: See TracChangeset for help on using the changeset viewer.