-
Notifications
You must be signed in to change notification settings - Fork 264
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
OSConsistencyManager
& IAM fetch read-your-write consistency implementation
#1486
Conversation
OSConsistencyManager
& IAM fetch read-your-write consistency implementation
4fbe142
to
7f07d0a
Compare
ebcda07
to
8be39ed
Compare
6dbf0ca
to
d546445
Compare
private override init() {} | ||
|
||
// Function to set the token in a thread-safe manner | ||
@objc public func setRywToken(id: String, key: OSIamFetchOffsetKey, value: String?) { |
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.
The only expected usage of this method is for IAM Fetch?
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.
The entire class can be used in the future for other RYW consistency projects!
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.
Ok, I wanted to clarify as the parameter is explicitly OSIamFetchOffsetKey
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.
Whoops that's a mistake
iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/Consistency/OSConsistencyManager.swift
Outdated
Show resolved
Hide resolved
iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/Consistency/IamFetch/OSIamFetchReadyCondition.swift
Outdated
Show resolved
Hide resolved
iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.m
Outdated
Show resolved
Hide resolved
iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSubscriptionOperationExecutor.swift
Outdated
Show resolved
Hide resolved
iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModelStoreListener.swift
Show resolved
Hide resolved
iOS_SDK/OneSignalSDK/OneSignalOutcomes/Source/OutcomeEvents/OSSessionManager.h
Outdated
Show resolved
Hide resolved
iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/Consistency/OSCondition.swift
Outdated
Show resolved
Hide resolved
d26ad02
to
10e877b
Compare
d5540ae
to
9c404e7
Compare
9c404e7
to
66dc1cd
Compare
Motivation: encapsulating object to keep rywTokens & rywDelays together Override equality
66dc1cd
to
279cce6
Compare
Motivation: Manages (kafka) offsets that function as read-your-write tokens for more accurate segment membership calculation. The manager works based on conditions & offsets. Offsets are stored in a nested map indexed by a unique id (e.g. `onesignalId`) and offset key (e.g. `USER_UPDATE`). This allows us to track offsets on a per-user basis (e.g. handle switching users). Conditions work by creating a blocking mechanism with customizable offset retrieval until a pre-defined condition is met (e.g. at least two specific offsets are available). OSCondition interface: allows extensibility for future applications to control offset blocking mechanism in consistency use-cases.
Motivation: custom condition to block offset retrieval until condition is met: user & subscription offsets are both available or just the user offset is available. This is because we always make a user update call (update the session count) but not always for subscription.
Motivation: commit new file references
…ager` Motivation: move into `OSSessionManager` to be accessible from other modules
Motivation: we need to pass the offset, session duration, & retry count to the GET IAM request.
Motivation: retry logic should work as follows: 1. initial request with offset --> failure 2. get retry limit & retry after from response & start retrying 3. if hit limit, make one final request with the offset: 0 The final request tells the backend, just show me what you got. Example: If the retry limit is 3 & we never get a successful response retrying, we should end up with 5 total requests.
Motivation: executors make the update or create requests and get back an offset which is saved in the consistency manager
Motivation: we need to flush the delta queue on start in order to immediately trigger updates that would return a RYW token so we can unblock IAM fetch as soon as possible.
Created a new target OneSignalOSCoreTests
Motivation: if we have a subscription update enqueued, we need to consider it. Otherwise we should just consider the userUpdateTokenSet.
Motivation: fix all lint issues
32cf760
to
663edc1
Compare
Motivation: On fresh installs, we don't yet have a user or a subscription to update so we wouldn't get a RYW token until those requests are executed (5 seconds later when the operations are processed)
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 RYW 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 tokens for a user or subscription state update.
Scope
OSConsistencyManager
implementationOSConsistencyManager
.OSConsistencyManager
.OSMessagingController
to delay IAM fetch until the token is available. Implements the retry logic.Testing
Unit testing
Manual Testing
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is