This repository was archived by the owner on Apr 26, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add type hints to synapse/storage/databases/main/events_worker.py
#11411
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
9f409cb
Add docstrings to `AbstractStreamIdGenerator` methods
2ce1c29
Create `AbstractStreamIdTracker` base class
6122b30
Make `_push_rules_stream_id_gen` an `AbstractStreamIdTracker`
a1c5c48
Remove duplicate `_EventCacheEntry` definition
c463c9d
Fix type hints for `SQLBaseStore.process_replication_rows`
ba8af67
Fix tpye hint for `_EventRow.room_version_id`
6cf127b
`_enqueue_events` needs a `Collection` since it uses `len()`
de0585a
`get_events_as_list` needs a `Collection`
5de79f1
Add type hints to `synapse/storage/databases/main/events_worker.py`
9bac798
Add newsfile
b40e5c4
Address PR feedback
50742a0
Improve IdGenerator docstrings
b4dbe02
Merge branch 'develop' into squah/type_hint_events_worker
squahtx ad514de
Fix typo in docstring
87fe9c6
Fix merge
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Aha.
It feels a bit icky, but I take your point that it's no worse than the situation we have today.
Is the pain here that we end up checking
hs.config.worker.worker_appmidway through? It seems odd to have to do so when the store is called aPushRuleWorkerStore.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's more to do with what's in
process_replication_rowss - we would have to check that theid_gens we update areSlavedIdTrackersorMultiWriterIdGeneratorsotherwise.There are really 3 interfaces:
IdStatus(?): get_current_token(), get_current_token_for_writer(), for getting the current stream idIdTracker(IdStatus): advance(), for instances that get notified about writesIdGenerator(IdStatus): get_next(), get_next_mult(), for instances that do the writesStreamIdGeneratoris used by instances that perform writes, with the expectation that they are the only writer.MultiWriterIdGeneratoris both anIdGeneratorandIdTrackerbut requires Postgres, which is whyStreamIdGeneratorexists.I didn't want to create a third abstract class. And
get_current_token_for_writerwas already out of place onStreamIdGeneratorThere 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.
Thanks for writing that out---this is gold dust! Would it be worth sticking that as a module-level comment or docstring somewhere?
Uh oh!
There was an error while loading. Please reload this page.
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 took a while to understand all the id trackers/generators well enough to write docstrings. Let me know what you think.