Skip to content

Conversation

@jason-bragg
Copy link
Contributor

Problem: Currently, a grain can only subscribe once to a given stream. A grain calling SubscribeAsync multiple times on the same stream would reset it's existing pubsub subscription rather than creating a new subscription. This limits certain scenarios, for example when a grain wants to subscribe to a stream simultaneously from different points in time (providing different SequenceTokens).

In the fix, each subscribe call creates it's own subscription to a stream, and multiple subscriptions (even from different points in the stream if recovery token is provided) can be established by a single grain. Each subscription can also be independently unsubscribed, allowing what we call proper Subscription multiplicity.

NOTE: Of course, naturally, a grain that subscribes multiple times to the same stream will receive the events multiple times, once by the observer of each subscription.

…final pass and didn't wait final if it got to end of loop.
Renamed SubscriptionMultiplicityTests to SubscriptionMultiplicityTestRunner and included it into test using composition rather than inheritance.
@gabikliot gabikliot self-assigned this Mar 6, 2015
@gabikliot gabikliot changed the title Subscription multiplicity Stream Subscription Multiplicity Mar 6, 2015
@veikkoeeva
Copy link
Contributor

I wonder should the parameters always be checked in Orleans codebase except in cases otherwise stated for some reason? There seem to a lot of code that takes parameters and uses them to search, say, some internal collection. That .NET framework code would do checking, but I'm wondering a bit of the side what's the "tone of the codebase", e.g. always check parameters (preconditions) explicitly, comment functions etc.

@jason-bragg
Copy link
Contributor Author

Fair point to explore. I think hardening the public customer facing APIs would be a good place to start. There were definitely opportunities to improve the code in this PR that I didn’t take. Soon I’ll be making another pass to further address subscription related issues. I’ll opportunistically perform code cleanup during these changes.

@gabikliot
Copy link
Contributor

I think the parameters should be checked on all public and maybe protected functions.
For internal I don't think we need to be so harsh. It is up tot he implementer. A good strategy for internals I think should be if this internal module is actually a self-contained module, with clear contract with other modules. The module is internal to application code, but if you think about it inside the runtime, it has a "public API" with other runtime modules. In such cases it can also do argument checks, to validate that its contract with other runtime modules. An example is MembershipOracle (or ActivationCollector). It is internal, but inside the runtime it interacts with other unrelated components and this interaction can/should be validated.
However, if 2 internal classes are part of the same logical component (so really together they are as if one component), I don't think we have to check the arguments there.

@jason-bragg
Copy link
Contributor Author

Please hold this PR. I need to refactor the IStreamProvider and IStreamProviderImpl interfaces to address issues regarding implementation of custom stream providers. This CR did not introduce the problem, but exasperates it.

@jason-bragg
Copy link
Contributor Author

PR updated.
IStreamProviderImpl interface has been cleaned up and is now public. Stream providers developed externally need to conform to the IStreamProviderImpl interface to fit into the streaming infrastructure.

@jason-bragg
Copy link
Contributor Author

Withdrawing pull request to handle a couple edge cases it introduces.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants