Skip to content

Standardise on current_stream_pos nomenclature for current stream positions #19685

@reivilibre

Description

@reivilibre

Spawning from #19453 (comment) (cc @MadLittleMods)

We have several ways in the code that we refer to the 'minimum position of all writers to a stream'; essentially the latest position that readers can read up to:

  • stream_token e.g. get_to_device_stream_token
  • current_key e.g. self.sources.account_data.get_current_key()
  • max_stream_id e.g. get_max_push_rules_stream_id
  • current_stream_id e.g. get_current_quarantined_media_stream_id

The max_stream_id name is particularly confusable with 'max allocated', which is the 'maximum position of all writers to a stream'.
(This max_stream_id name is also what the 'new' streams — thread_subscriptions, sticky_events, profile updates and media quarantine, have been using. I think this stemmed from me cribbing from account_data which uses this name and then writing the 'Cheatsheet for creating a new stream' with that, which others have referred to)

Would be nice to unify these to a single name (though note: it might make sense to exclude the events stream from the discussion, since we have both a min and max there and therefore it's hard to drop the 'max' name.... although we call those the room_min and room_max even though it's about the events stream :S).

I sought some opinions from the team (internal), which I summarise here:

  • @erikjohnston > I'd probably go with something like current_token . A stream_token sounds like it could be any valid token, and max_token sounds like it could be the maximum issued integer ID potentially
  • @anoadragon453 > -0.2 from me on token is that we have a sync token which contains structured data within it. An id just sounds like a number.
  • @erikjohnston > I'm not a mad fan of using id as they aren't IDs but instead are positions
  • @anoadragon453 > pos sounds good to me. We have used stream_pos(ition) in the past, if I recall.
  • @reivilibre likes current_pos (unifies the above two points)
  • @anoadragon453 > I like including stream. current_stream_pos?

I will go through and update our stream docs and what I can of the codebase to follow this new convention that has settled.

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions