-
Notifications
You must be signed in to change notification settings - Fork 368
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
Read-Your-Write Consistency #2168
Conversation
ecaef33
to
4ecae20
Compare
f54bc44
to
1bf9985
Compare
...SDK/onesignal/core/src/main/java/com/onesignal/common/consistency/impl/ConsistencyManager.kt
Outdated
Show resolved
Hide resolved
...SDK/onesignal/core/src/main/java/com/onesignal/common/consistency/impl/ConsistencyManager.kt
Show resolved
Hide resolved
...SDK/onesignal/core/src/main/java/com/onesignal/common/consistency/impl/ConsistencyManager.kt
Show resolved
Hide resolved
...SDK/onesignal/core/src/main/java/com/onesignal/common/consistency/impl/ConsistencyManager.kt
Outdated
Show resolved
Hide resolved
OneSignalSDK/onesignal/core/src/main/java/com/onesignal/user/UserModule.kt
Outdated
Show resolved
Hide resolved
...in/java/com/onesignal/user/internal/operations/impl/executors/UpdateUserOperationExecutor.kt
Outdated
Show resolved
Hide resolved
...l/in-app-messages/src/main/java/com/onesignal/inAppMessages/internal/InAppMessagesManager.kt
Outdated
Show resolved
Hide resolved
...l/in-app-messages/src/main/java/com/onesignal/inAppMessages/internal/InAppMessagesManager.kt
Outdated
Show resolved
Hide resolved
...l/in-app-messages/src/main/java/com/onesignal/inAppMessages/internal/InAppMessagesManager.kt
Outdated
Show resolved
Hide resolved
...sages/src/main/java/com/onesignal/inAppMessages/internal/backend/impl/InAppBackendService.kt
Outdated
Show resolved
Hide resolved
...K/onesignal/in-app-messages/src/main/java/com/onesignal/inAppMessages/InAppMessagesModule.kt
Outdated
Show resolved
Hide resolved
...lSDK/onesignal/core/src/main/java/com/onesignal/common/consistency/IamFetchReadyCondition.kt
Outdated
Show resolved
Hide resolved
...al/core/src/main/java/com/onesignal/user/internal/backend/impl/SubscriptionBackendService.kt
Show resolved
Hide resolved
...al/core/src/main/java/com/onesignal/user/internal/backend/impl/SubscriptionBackendService.kt
Show resolved
Hide resolved
.../onesignal/core/src/main/java/com/onesignal/user/internal/backend/impl/UserBackendService.kt
Show resolved
Hide resolved
.../java/com/onesignal/user/internal/operations/impl/executors/SubscriptionOperationExecutor.kt
Outdated
Show resolved
Hide resolved
...in/java/com/onesignal/user/internal/operations/impl/executors/UpdateUserOperationExecutor.kt
Outdated
Show resolved
Hide resolved
...in/java/com/onesignal/user/internal/operations/impl/executors/UpdateUserOperationExecutor.kt
Outdated
Show resolved
Hide resolved
de84378
to
a16a968
Compare
a16a968
to
5b8760f
Compare
f5a6a2b
to
51aaa8b
Compare
601ec15
to
bc9963b
Compare
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.
this LGTM from a non-iOS expert view
Manages read-your-write tokens. The manager works based on conditions & tokens. Tokens are stored in a nested map indexed by a unique id (e.g. `onesignalId`) and a token key (e.g. `USER`). This allows us to track tokens on a per-user basis (e.g. handle switching users). Conditions work by creating a blocking mechanism with customizable token retrieval until a pre-defined condition is met (e.g. at least two specific tokens are available). Also allows extensibility for future applications to control offset blocking mechanism in consistency use-cases.
Inject ConsistencyManager where it will be used.
Motivation: custom condition to block token retrieval until condition is met. We then return the newest token
Motivation: support passing values as headers, add comments
Motivation: need the offsets to be available to set in the ConsistencyManager
Motivation: the IAM fetch call (`listInAppMessages`) will include the rywToken, retryCount, & secondsSinceAppOpen (tracked on backend) We update the request & related code here. Handle retry logic
Motivation: we want to update the user as soon as possible in order to not delay IAM fetch
Motivation: to be used to index read your write tokens specific to the IamFetch consistency use case
Motivation: the executors call the respective backend services who's result will include the token value. We then hold in memory via `setRywToken`
Motivation: offset, secondsSinceAppOpen, & retryCount will be sent as headers
bc9963b
to
2083bd0
Compare
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.
Left a few more comments in the code.
Also a few more things not in the code:
- Manual testing still says "// TO DO"
- Some other things not checked off in the PR check list.
- Does this code work with that is available on the backend today? If not we will need to either wait until the backend is shipped until we merge this PR into main, or make changes to this PR to support that.
...lSDK/onesignal/core/src/main/java/com/onesignal/common/consistency/IamFetchReadyCondition.kt
Outdated
Show resolved
Hide resolved
...sages/src/main/java/com/onesignal/inAppMessages/internal/backend/impl/InAppBackendService.kt
Outdated
Show resolved
Hide resolved
...sages/src/main/java/com/onesignal/inAppMessages/internal/backend/impl/InAppBackendService.kt
Outdated
Show resolved
Hide resolved
...sages/src/main/java/com/onesignal/inAppMessages/internal/backend/impl/InAppBackendService.kt
Outdated
Show resolved
Hide resolved
@jkasten2 yes. backend changes have been shipped |
7707564
to
55a3e25
Compare
Description
One Line Summary
Introduce and integrate a ConsistencyManager to manage read-your-write tokens for improved segment membership calculation.
Details
Motivation
This update introduces the ConsistencyManager to manage kafka offsets, which are used as read-your-write tokens. The goal is to improve the accuracy of segment membership calculations by providing an open-ended & highly customizable blocking mechanism for operations that rely on having successfully synchronized client & server state.
For a first use-case, we want to block the fetching of IAMs until we have offsets for a user & subscription state update.
Scope
listInAppMessages
request.Testing
Unit testing
ConsistencyManager
classManual testing
Tested on Android emulator
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is