Skip to content

Commit

Permalink
fixup! net: Enhance observation management with ETag tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielius1922 committed Aug 8, 2023
1 parent 906eb11 commit 1bc3811
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions net/observation/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,17 @@ func (o *Observation[C]) wantBeNotified(r *pool.Message) bool {

o.private.mutex.Lock()
defer o.private.mutex.Unlock()
if ValidSequenceNumber(o.private.obsSequence, obsSequence, o.private.lastEvent, now) {
o.private.obsSequence = obsSequence
o.private.lastEvent = now
if etag, err := r.ETag(); err == nil {
o.private.etag = etag
}
return true
if !ValidSequenceNumber(o.private.obsSequence, obsSequence, o.private.lastEvent, now) {
return false
}

return false
o.private.obsSequence = obsSequence
o.private.lastEvent = now
if etag, err := r.ETag(); err == nil {
if len(o.private.etag) != len(etag) {
o.private.etag = make([]byte, len(etag))
}
copy(o.private.etag, etag)
}
return true
}

0 comments on commit 1bc3811

Please sign in to comment.