-
Notifications
You must be signed in to change notification settings - Fork 140
[4.0.3 backport] CBG-5076: remove serialisation from caching process #7984
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: release/4.0.3
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR removes serialization from the channel caching process by eliminating the pre-computed serialization string from the channels.ID type. The change simplifies the channel ID representation and removes the dependency on string-based key matching in the change listener.
Changes:
- Modified
channels.IDto remove theserializationfield and update itsString()method to return only the channel name - Updated
changeListenerto usechannels.IDdirectly as map keys instead of strings - Adjusted test expectations to reflect the simplified string representation of channel sets
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| channels/set.go | Removed serialization field from ID struct and simplified String() method to return only channel name |
| db/change_listener.go | Changed keyCounts map and related methods to use channels.ID instead of string keys, added collection ID constant for principal documents |
| channels/set_test.go | Updated test expectations to match new string representation without collection ID prefix |
| // String returns the channel name as a string, omitting the collection ID, so beware when using for logging purposes | ||
| // that the collection name is logged from the context on the log line |
Copilot
AI
Jan 16, 2026
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 comment warns about logging implications but doesn't specify what "context on the log line" means. Consider clarifying what context is expected to provide the collection ID information, or provide an example of proper usage.
| // String returns the channel name as a string, omitting the collection ID, so beware when using for logging purposes | |
| // that the collection name is logged from the context on the log line | |
| // String returns only the channel name, and intentionally omits the collection ID. | |
| // When using this in log messages, always include the collection identifier separately in the | |
| // log context or format string (for example: "collection %d channel %s"). |
| // unusedSeqChannelID marks the unused sequence key for the channel cache. This is a marker that is global to all collections. | ||
| var unusedSeqChannelID = channels.NewID(unusedSeqKey, unusedSeqCollectionID) | ||
|
|
||
| // principalDocCollectionIDForChannelID is the collection ID for construction of channel ID for principal documents (users, roles). |
Copilot
AI
Jan 16, 2026
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 comment should explain why collection ID 0 is used for principal documents and whether this is a special/reserved value. This magic number would benefit from additional context about its significance.
| // principalDocCollectionIDForChannelID is the collection ID for construction of channel ID for principal documents (users, roles). | |
| // principalDocCollectionIDForChannelID is the (synthetic) collection ID used when constructing | |
| // channel IDs for principal documents (users, roles). Principals are global and are not stored | |
| // in a normal data collection, so they are associated with this reserved collection ID (0) only | |
| // for the purposes of channel identification. This value must not overlap any real collection ID. |
[4.0.3 backport] CBG-5076: remove serialisation from caching process
cherry-pick of 9a42542