Skip to content
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

LoadBalancer should always consider the first events as initial state #3004

Merged

Conversation

idelpivnitskiy
Copy link
Member

@idelpivnitskiy idelpivnitskiy commented Jul 12, 2024

Motivation:

Currently, both implementations of the LoadBalancer assume 2 possibilities for the first events collection after re-subscribe: "state of the world" or "delta" and try to infer which one it is based on what event statuses are present in the collection. However, it doesn't provide any guarantees because even if SD impl keeps returning deltas after a re-subscribe, a delta can contain only AVAILABLE events, but it will be incorrectly interpreted as "state of the world".

Because of Reactive Streams rule clarified in #3002, LoadBalancer implementations should always expect "state of the world" for the first events after re-subscribe.

Modifications:

  • Remove inference of the first collection of events after re-subscribe and always expect a new subscriber to start from "state of the world".
  • Update resubscribeToEventsWhenAllHostsAreUnhealthy() test to reflect behavior change.

Result:

Both LoadBalancer implementations follow ServiceDiscoverer contract and expect the first collection of events after re-subscribe to represent a "state of the world".

Motivation:

Currently, both implementations of the `LoadBalancer` assume 2
possibilities for the first events collection after re-subscribe:
"state of the world" or "delta" and tries to infer which one it is based
on what event statuses are present in the collection. However, it
doesn't provide any guarantees because even if SD impl keeps returning
deltas after a re-subscribe, a delta can contain only `AVAILABLE`
events, but it will be incorrectly interpreted as "state of the world".

Because of Reactive Streams rule clarified in apple#3002, `LoadBalancer`
implementations should always expect "state of the world" for the
first events after re-subscribe.

Modifications:

- Remove inference of the first collection of events after resubscribe
and always expect a new subscriber to start from "state of the world".
- Update `resubscribeToEventsWhenAllHostsAreUnhealthy()` test to reflect
behavior change.

Result:

Both `LoadBalancer` implementations follow `ServiceDiscoverer` contract
and expect the first collection of events after re-subscribe to
represent a "state of the world".
@idelpivnitskiy idelpivnitskiy merged commit e3759e8 into apple:main Jul 15, 2024
11 checks passed
@idelpivnitskiy idelpivnitskiy deleted the firstEventsAfterResubscribe branch July 15, 2024 16:10
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.

2 participants