Discussion: data/stream/rpc reliability #702
Draft
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.
Problem
Our data-related APIs do not (or indirectly) validate the state of their
destinationIdentity
which seriously impacts the reliability of such channels. It moves the responsibility to handle these state transitions to the consumer, respond to properParticipant
lifecycle events, etc.Reasoning about the order of events is impossible without server-side knowledge, handling all the combinations - highly impractical, and counter-intuitive (like participant already subscribed to a track, but cannot receive data from a data channel).
Consumers shouldn't be exposed to transport internals and their distributed nature. In most practical applications, we can just assume that if the
Participant.Identity
is returned somewhere, it's also "valid" for communication (regardless of the channel).Swift Status Quo
Sending messages to inactive/non-existing participants will lead to:
room.localParticipant.performRpc
- willtimeout
after 10s, but the API suggests:room.localParticipant.publish(data:)
- only checks publisher's own transport viapublisherTransportConnectedCompleter
- will return immediatelyroom.room.localParticipant.sendText
and other streams - will just return immediatelySolution
Publisher
Always check for local transport, then
await
, reuse this part across 3+ APIs. This change is purely internal and should not break any existing behaviors.Receivers
Add public option(s) to wait for the receivers with a consistent timeout, reuse this part across 3+ APIs. Technically, it's not super hard, as all the APIs are already
async
. New errors for opt-iners.RPC example attached.
Questions
Which modes do we really need?
waitUntilActive
(mirroring publisher side), formingParticipant.Identity
fromString
should not be that popular, so we assume theParticipant
exists somewhere amongallParticipants
already. If not, just throw immediately."As soon as someone joins"
waitUntilActive
sequence.How to handle multiple destinations (any/all = optimistic/pessimistic)?