Adjudicator subscription logic #210
Replies: 3 comments 2 replies
-
Im generally in favor simplifying the subscription logic as I see several downsides of the current implementation but not really clear benefits. However, I wonder: What was the intention behind choosing the more complex design in the first place? Are we losing some benefits if we change to a simpler subscription logic? |
Beta Was this translation helpful? Give feedback.
-
As I currently understand, you are suggesting that a subscription should always return all past and future events. One downside could be that a ledger backend does not provide the functionality to retrieve historic events. Maybe a more widely supported approach would be that we simply guarantee that all events from the point of starting the subscription will be returned. In that case, we would need to make sure that all users of the subscription start it before they expect events. In some cases, however, it may be necessary to retrieve the most recent event, for example, when resuming a client. For this, we would need an additional function that guarantees the retrieval of the latest event. In any case, we could probably remove the requirement that only the latest event should be returned and instead allow the subscription to return all events. I can't imagine that this requirement has any clear benefits that outweigh the complexity introduced by it because a subscription user must be able to handle all events anyways. |
Beta Was this translation helpful? Give feedback.
-
Context
Currently, the adjudicator subscription is designed in such a way that, calling the
Next
method returns the latest event. For instance, when initializing the subscription,Next
will return the 4th registered event.Next
will return the progressed event.Next
will return the 2nd progressed event.Next
will return the concluded event.In all the 3 cases, further calls to
Next
will block until a future event occurs and returns it. If the subscription is closed,Next
always returnsnil
.Problem
This design has caused a few inconveniences when using the subscription.
ensureRegistered
to detect if a channel is registered: a channel is registered if there is a registered event, progressed event or concluded event.Possible solutions
I thought, by redesigning the subscription, we could
For this, we will have to
Next
method to return a channel, into which all the adjudicator events (past and future) will be dumped into.We could also rename the
Next
method, if required.for-select
pattern.for-select-default
pattern.With little modification, it is also possible to retrieve the latest Registered Event, latest Progressed Event or latest Concluded Event.
Beta Was this translation helpful? Give feedback.
All reactions