Skip to content

Conversation

@torcolvin
Copy link
Collaborator

[4.0.3 backport] CBG-5076: remove serialisation from caching process

cherry-pick of 9a42542

Copilot AI review requested due to automatic review settings January 16, 2026 16:00
Copy link
Contributor

Copilot AI left a 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.ID to remove the serialization field and update its String() method to return only the channel name
  • Updated changeListener to use channels.ID directly 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

Comment on lines +38 to +39
// 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
Copy link

Copilot AI Jan 16, 2026

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.

Suggested change
// 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").

Copilot uses AI. Check for mistakes.
// 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).
Copy link

Copilot AI Jan 16, 2026

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.

Suggested change
// 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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants