-
-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: Enhance observation management with ETag tracking #469
Conversation
This commit introduces an enhancement to the observation mechanism in the network module by implementing ETag tracking. The latest ETag value associated with each observation is now stored in the internal representation. With this update, each incoming message containing the ETag CoAP option automatically updates the ETag value for the relevant observation. When an observation is canceled, the stored ETag value is utilized. When the server detects a valid ETag match, it now responds with a VALID code and an empty payload instead of resending the content of the resource. This optimization minimizes unnecessary data transfer and reduces network load.
443f67c
to
906eb11
Compare
Codecov Report
@@ Coverage Diff @@
## master #469 +/- ##
==========================================
+ Coverage 72.16% 72.26% +0.10%
==========================================
Files 70 70
Lines 5461 5470 +9
==========================================
+ Hits 3941 3953 +12
+ Misses 1123 1120 -3
Partials 397 397
|
net/observation/handler.go
Outdated
@@ -240,6 +251,9 @@ func (o *Observation[C]) wantBeNotified(r *pool.Message) bool { | |||
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use copy instead of assignation -> the underlayer buffer could be reused.
on new observation preallocate buffer with 8 bytes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy() copies works based on length not capacity, so if the lengths do not match I have to allocate a new slice
83b1eb9
to
1bc3811
Compare
Kudos, SonarCloud Quality Gate passed! |
* net: Enhance observation management with ETag tracking This commit introduces an enhancement to the observation mechanism in the network module by implementing ETag tracking. The latest ETag value associated with each observation is now stored in the internal representation. With this update, each incoming message containing the ETag CoAP option automatically updates the ETag value for the relevant observation. When an observation is canceled, the stored ETag value is utilized. When the server detects a valid ETag match, it now responds with a VALID code and an empty payload instead of resending the content of the resource. This optimization minimizes unnecessary data transfer and reduces network load. --------- Co-authored-by: Jozef Kralik <[email protected]>
This commit introduces an enhancement to the observation mechanism in the network module by implementing ETag tracking. The latest ETag value associated with each observation is now stored in the internal representation.
With this update, each incoming message containing the ETag CoAP option automatically updates the ETag value for the relevant observation. When an observation is canceled, the stored ETag value is utilized. When the server detects a valid ETag match, it now responds with a VALID code and an empty payload instead of resending the content of the resource. This optimization minimizes unnecessary data transfer and reduces network load.