-
-
Notifications
You must be signed in to change notification settings - Fork 17
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
hub: efficient Device Twin Synchronization #1005
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jkralik
force-pushed
the
jkralik/feature/etag
branch
7 times, most recently
from
July 21, 2023 14:02
9a55345
to
b68e708
Compare
jkralik
force-pushed
the
jkralik/feature/etag
branch
3 times, most recently
from
August 1, 2023 13:26
0bf2427
to
d01851a
Compare
jkralik
force-pushed
the
jkralik/feature/etag
branch
from
August 4, 2023 08:27
2094305
to
b95d062
Compare
jkralik
force-pushed
the
jkralik/feature/etag
branch
from
August 10, 2023 09:09
102c5b5
to
c9c9644
Compare
Danielius1922
approved these changes
Aug 11, 2023
In order to monitor resource changes and determine if a resource has been modified on the device, the CoAP gateway utilizes the Entity Tag (ETAG) mechanism. For Batch Observation, the ETAG is associated with the overall state of resources. Prior to initiating resource observation, the CoAP gateway retrieves the latest ETAG among all device resources from the Hub Database. When initiating the resource observation, the CoAP gateway sends the ETAG to the device. If the received ETAG matches the highest ETAG among the device resources, the device responds with a code VALID. However, if the received ETAG does not match, the device responds with a code CONTENT and includes the current ETAG. Consequently, when a resource changes, the device sends the updated ETAG back to the CoAP gateway via a notification. The CoAP gateway transmits the ETAG together with the Content by using the NotifyResourceChanged method to the resource-aggregate. This command is then converted into a ResourceChanged event, which is saved in a database and distributed through the event bus. In cases where multiple resources change simultaneously, the CoAP gateway updates all affected resources with the same timestamp and ETAG. The special query to the database efficiently retrieves the latest ETAG value from all device resources without loading the complete set of data. This optimized query solely focuses on performance and retrieves only the required ETAG value, excluding any additional information.
Force resynchronization refers to the process of refreshing all resources from the device and updating the twin. Its primary purpose is to resolve potential synchronization issues and ensure there are no operational discrepancies between the device and its twin. It also enable twin.
jkralik
force-pushed
the
jkralik/feature/etag
branch
from
August 31, 2023 11:18
c9c9644
to
89e307d
Compare
ondrejtomcik
reviewed
Sep 4, 2023
resource-aggregate/cqrs/eventstore/mongodb/getLatestDeviceETAG.go
Outdated
Show resolved
Hide resolved
resource-aggregate/cqrs/eventstore/mongodb/getLatestDeviceETAG_test.go
Outdated
Show resolved
Hide resolved
ondrejtomcik
reviewed
Sep 4, 2023
ondrejtomcik
reviewed
Sep 4, 2023
ondrejtomcik
reviewed
Sep 4, 2023
ondrejtomcik
reviewed
Sep 4, 2023
jkralik
force-pushed
the
jkralik/feature/etag
branch
2 times, most recently
from
September 5, 2023 07:23
7f3c7e7
to
5597d18
Compare
jkralik
force-pushed
the
jkralik/feature/etag
branch
from
September 5, 2023 07:23
5597d18
to
e7d8578
Compare
Kudos, SonarCloud Quality Gate passed! |
ondrejtomcik
approved these changes
Sep 5, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In order to monitor resource changes and determine if a resource has been modified on the device, the CoAP gateway utilizes the Entity Tag (ETAG) mechanism.
For more information, please refer to the documentation.