Improve persistent stream provider configuration pattern
Persistent stream providers are very complex, it has many components which user can customize. Now the configuration of those components has scattered in three places, one is through inheritance, another one is through giant god stream provider options which is intended to configure everything, third one is through the component's own option. All three of them has pain points, listed below.
-
Use inheritance, instead of DI to configure some core component, such as
CheckpointerFactory,QueueMapperFactory,StreamFailureHandlerFactorysetters onTAdapterFactory. This make configuring harder, since if user want to configure those, they need to actually have a reasonable understanding of how Orleans streaming is wired up internally, to know which class to inherit and when to set those factories. Although this is true before, so one may argue it might be fine now. But the fact is, after provider been integrated with lifecycle, its configuration process has been changed entirely. For users who configured those factory through inheritance, they cannot use our extension methods to configure their custom stream provider, and the configuration their are familiar with is gone, and they need to get used to a new one which is almost as bad as before. So I think we should kill this pain point because we provided a new configuration method, it will suck if it is as bad as before. -
The disadvantage of god stream provider options is its poor flexibility, extensibility and complexity. I will skipped listing its cons here since I think there's a consensus on Why god configuration is bad.
-
Configure one component through its own option is the way to go forward. The problem with it right now is poor discoverability, especially when the configuration is in three places. For example, to configure a queue balancer now, you need to first set the queue balancer type right in the stream provider options, then you need to configure the specific type of queue balancer options through DI, which there's no extra infrastructure to guide you on how to do that.
I would argue some of those need to be improved in 2.0 scope, because we create a fuss to provide a new way of configuration, it will be bad if this new configuration method is as bad as before, and user need to learn about this new bad way and adapt to it, instead of happily adapt a better way.
General direction is to uniform these three ways of configuration and develop one consistent and better way to configure stream providers, which also has good discoverability, extensibility and flexibility.
For a number of reasons, I won't go into, most of the complexity in the PersistentStreamProvider is due to it's queue adapter and queue adapter factory, which, now that we're using DI and names services, can probably mostly be replaced by various named services.
Some of these are:
- IQueueAdapter (which should probably be IQueueAdapterSender)
- IQueueAdapterReceiver
- IQueueAdapterCache (possibly just IQueueCache)
- IStreamQueueMapper
- IStreamFailureHandler
Each of the above components can be independently configured. It should also be noted that many of these components are related to the PersistentStreamPullingAgent, which, as a queue processor, is not well suited to unordered streams (like azure queue). If we make the queue processing logic a named service as well, we can support more queue processing patterns which are more suited to specific queue capabilities. If we do this, many of the above services would be part of the queue processer 'builder' rather than the PersistentStreamProvider builder.
In any case, for the complexity of this system, I advocate some prototyping and upfront design.
Resolved via #4164.