Unify PubSub Handler Signature
Motivation
Right now the PubSub handlers are split into three separate closures, with the subscribe/unsubscribe handlers being optional. This won't play well with AsyncStream for being able to respond to all events that a PubSub subscription can cause.
Additionally, the current structure is very verbose in code to maintain - but also adds complexity to developers who are first getting started to understand the lifecycle of PubSub events.
Changes
- Add: New
RedisPubSubEvent
enum that captures the subscribe, unsubscribe, and message lifecycle events - Add: New
RedisPubSubEventReceiver
that combines the previous 3 closure types - Add: Dedicated DocC Symbol Extension file for
RedisPubSubHandler
- Change:
RedisClient.subscribe
andRedisClient.psubscribe
method signatures to only require a single unlabeled closure - Rename:
RedisUnsubscribeEventSource
toRedisPubSubEvent.UnsubscribeEventSource
- Remove:
RedisSubscriptionMessageReceiver
,RedisSubscriptionChangeDetails
,RedisSubscribeHandler
, andRedisUnsubscribeHandler
types
Result
Developers should have a much easier time getting started and understanding PubSub with assistance from the compiler with types to understand what they're being given and what's available to them as information to make more informed decisions in their app logic.