-
Notifications
You must be signed in to change notification settings - Fork 360
refactor(remote-config): replace kPreUpdate with batch handler API (DEBUG-4402) #7121
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
base: master
Are you sure you want to change the base?
Conversation
b704693 to
eec9001
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7121 +/- ##
==========================================
+ Coverage 84.78% 84.81% +0.02%
==========================================
Files 521 522 +1
Lines 22155 22207 +52
==========================================
+ Hits 18785 18834 +49
- Misses 3370 3373 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Overall package sizeSelf size: 4.36 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------| | import-in-the-middle | 2.0.0 | 68.46 kB | 797.03 kB | | dc-polyfill | 0.1.10 | 26.73 kB | 26.73 kB |🤖 This report was automatically generated by heaviest-objects-in-the-universe |
eec9001 to
3efdc4c
Compare
3efdc4c to
b49c683
Compare
This comment has been minimized.
This comment has been minimized.
- Remove the leaky kPreUpdate hook and introduce a first-class batch API: setBatchHandler()/removeBatchHandler() - Introduce explicit product subscription via subscribeProducts()/ unsubscribeProducts(), and have setProductHandler()/ removeProductHandler() subscribe/unsubscribe for clarity - Centralize ASM/WAF RC product names in appsec/rc-products.js - Update AppSec WAF RC integration to use batched tx (ack/error/markHandled) instead of mutating configs - Improve JSDoc/TS inference for batch transaction/descriptors and WAF manager typing
b49c683 to
c18a9fe
Compare
BridgeAR
left a comment
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.
It seems like a good improvement to separate things by product. Just left a few minor suggestions
| let appliedActions = new Map() | ||
|
|
||
| /** | ||
| * @param {{ rules?: string, [key: string]: any }} config |
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.
Nit: I see the improvement, while I would like to prohibit adding any any to the code base
|
|
||
| item.apply_state = ACKNOWLEDGED | ||
| tx.ack(item.path) | ||
| tx.markHandled(item.path) |
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.
I think we could just implicitly mark it as handled when there is an ack or an error. That way the code is simpler.
| version: conf.version, | ||
| file: conf.file | ||
| } | ||
| return Object.freeze(desc) |
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.
Do we need to freeze the objects?
|
|
||
| if (toUnapply.length || toApply.length || toModify.length) { | ||
| this.emit(RemoteConfigManager.kPreUpdate, { toUnapply, toApply, toModify }) | ||
| const tx = createUpdateTransaction({ toUnapply, toApply, toModify }, txHandledPaths, txOutcomes) |
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.
I would strongly favor writing transaction instead of tx.
|
|
||
| this._handlers = new Map() | ||
| this._products = new Set() | ||
| this._batchHandlers = new Map() |
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.
Please use private properties instead

What does this PR do?
kPreUpdatehook fromRemoteConfigManagerand replaces it with a first-class batch handler API (setBatchHandler/removeBatchHandler) that receives an explicit transaction (ack/error/markHandled).subscribeProducts(...products)/unsubscribeProducts(...products)and makessetProductHandler/removeProductHandlersubscribe/unsubscribe for clarity.appsec/rc-products.js.Motivation
kPreUpdateexposed internal mutable state and blurred responsibility between RC internals and consumers. WAF needs to reconcile multiple products in one logical update, so the new batch API provides a safer and clearer surface.