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
Introduce device id v2 #362
Merged
+332
−35
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4e5ed88
uuid init
darkdh 9e96726
deviceIdV2 and SQS queue migration
darkdh 77af179
Emit SAVE_INIT_DATA for existing devices to update deviceIdV2
darkdh 0387b4e
fix legacy device id reset issue
darkdh f6a25c1
Add device id v2 test
darkdh File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.
Loading status checks…
fix legacy device id reset issue
fix test add comments
- Loading branch information
darkdh
committed
Dec 2, 2019
darkdh
Anthony Tseng
commit 0387b4ec20788c34905e69162028183674f122ba
Verified
This commit was signed with a verified signature.
GPG key ID: E14094A20D3AAEEC
Learn about signing commits
| @@ -251,18 +251,21 @@ RequestUtil.prototype.list = function (category, startAt, maxRecords, nextContin | ||
| WaitTimeSeconds: CONFIG.SQS_MESSAGES_LONGPOLL_TIMEOUT | ||
| } | ||
|
|
||
| // We will fetch from both old and new SQS queues until old one gets retired | ||
| if (this.oldSQSUrlByCat[category]) { | ||
| let oldNotificationParams = Object.assign({}, notificationParams) | ||
| oldNotificationParams.QueueUrl = `${this.oldSQSUrlByCat[category]}` | ||
|
|
||
| return s3Helper.listNotifications(this.sqs, notificationParams, category, prefix).then((values) => { | ||
| return s3Helper.listNotifications( | ||
| this.sqs, notificationParams, category, prefix).then((values) => { | ||
| if (this.shouldRetireOldSQSQueue(parseInt(values.createdTimeStamp))) { | ||
| return this.deleteSQSQueue(this.oldSQSUrlByCat[category]).then(() => { | ||
AlexeyBarabash
Contributor
|
||
| delete this.oldSQSUrlByCat[category] | ||
| return values | ||
| }) | ||
| } | ||
| return s3Helper.listNotifications(this.sqs, oldNotificationParams, category, prefix).then((oldValues) => { | ||
| return s3Helper.listNotifications( | ||
| this.sqs, oldNotificationParams, category, prefix).then((oldValues) => { | ||
| if (deepEqual(values.contents, oldValues.contents, {strict: true})) { | ||
| return values | ||
| } | ||
| @@ -296,6 +299,13 @@ RequestUtil.prototype.shouldListObject = function (startAt, category) { | ||
| this.listInProgress === true | ||
| } | ||
|
|
||
| /** | ||
| * The retention time of our SQS queue is 24 hours so we will retire old SQS | ||
| * queue created by device id after 24 hours | ||
| * @param {number=} createdTimestamp is the when new device id v2 queue was | ||
| * created | ||
| * @returns {boolean} | ||
| */ | ||
| RequestUtil.prototype.shouldRetireOldSQSQueue = function (createdTimestamp) { | ||
| let currentTime = new Date().getTime() | ||
| let newQueueCreatedTime = | ||
| @@ -423,7 +433,6 @@ RequestUtil.prototype.createAndSubscribeSQS = function (deviceId, deviceIdV2) { | ||
| // Doesn't have to create about to deprecated queues | ||
| createSQSPromises.push(subscribeOldSQSforCategory(deviceId, CATEGORIES_FOR_SQS[i], this)) | ||
| createSQSPromises.push(createAndSubscribeSQSforCategory(deviceIdV2, CATEGORIES_FOR_SQS[i], this)) | ||
| // TODO(darkdh): encode into base64 | ||
| } | ||
|
|
||
| return Promise.all(createSQSPromises) | ||
| @@ -604,6 +613,10 @@ RequestUtil.prototype.purgeUserCategoryQueue = function (category) { | ||
| }) | ||
| } | ||
|
|
||
| /** | ||
| * Delete SQS queue by url | ||
| * @param {string} url - SQS queue url | ||
| */ | ||
| RequestUtil.prototype.deleteSQSQueue = function (url) { | ||
| return new Promise((resolve, reject) => { | ||
| let params = { | ||
ProTip!
Use n and p to navigate between commits in a pull request.
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.
@AlexeyBarabash reminded me that when device id is duplicated, if there is an old Brave which doesn't contain the fix, its SQS queue will be unavailable until next relaunch because upgraded Brave deletes it after 24 hours