-
Notifications
You must be signed in to change notification settings - Fork 186
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
Get undeleted state deltas #17833
base: develop
Are you sure you want to change the base?
Get undeleted state deltas #17833
Conversation
Emphasize that state deltas without an event ID are for deleted state.
c928ffb
to
25464b1
Compare
def get_current_state_deltas_txn( | ||
txn: LoggingTransaction, | ||
) -> Tuple[int, List[StateDelta]]: | ||
) -> Tuple[int, List]: |
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.
) -> Tuple[int, List]: | |
) -> Tuple[int, Union[List[StateDelta], List[StateDeltaWithEventId]]]: |
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.
This is unfortunately not as simple as it seems. Mypy considers that type as incorrect because it treats this function's actual return type not as a union of two different list types, but as a list of unions (List[Union[StateDelta, StateDeltaWithEventId]]
). Using that as the return type satisfies that error, but triggers a new error on mismatched types between the helper function & the containing function.
I attempted using generics to bypass this, but to no avail. For now the best I could think of was to use an unspecified List
, but I'm open to using something more specific than that.
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 good to have this context for this decision to look back on in any case ⏩
@@ -0,0 +1 @@ | |||
Allow `StateDeltasStore.get_partial_current_state_deltas` to exclude deltas for deleted state. |
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.
What's the context for these changes? Why were they made? What was it affecting? How did we notice? What scenarios does this happen in? Is this prerequisite work for something else?
Do we need to apply this to other functions that read from current_state_delta_stream
?
(update the PR description as well)
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 motivation was from another PR that wanted only eventID-associated deltas, and a recommendation was made to move that filtering into the getter instead: #17810 (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.
Do we need to apply this to other functions that read from
current_state_delta_stream
?
No, because this doesn't change the existing usage of the getters that don't filter out deltas based on eventID.
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.
(update the PR description with all of this context)
My question was more like if we need it it here, why don't we only take into account eventID-associated deltas in the other places. But it's actually just a very specific use case that doesn't care about deltas where state gets deleted. At the very least, this needs some more context to the docstring on why/when you would use the exclude_deleted
option.
I'm worried that we might be introducing easy foot-gun if we add this option. exclude_deleted
kinda sounds like it's excluding data that doesn't matter anymore. And it gives a "better" looking type where you don't have to worry about an optional event_id
.
And if you make these assumptions and try to use it; for example, if I grab the deltas between two tokens and then resolve it against a StateMap
, If I accidentally use the exclude_deleted
option, I would be missing the deltas where the state became unset and should be unset in the StateMap
.
The use case might be better served with how it's being addressed now 🤷
Pull Request Checklist
EventStore
toEventWorkerStore
.".code blocks
.(run the linters)