GROUP-89 Improve RSocket Services & Event Handling #21
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.
Description of Changes
Overhaul of the GroupHQ client based on common design patterns.
RSocket States
Tracking the state of RSocket connections is a complex task given the varying scenarios that can occur from the establishment of the connection itself, as well as the requests and streams over that connection. The state pattern helps to keep track of both, and is employed by RSocket Mediator classes to signal to upstream services the current state of their request.
RSocket Mediators
Working with RSocket requests is complex enough to warrant separate services. Previously, the RSocket services that we had were inflexible, as each was designed for one route and request type. Components would take on the responsibility of observing streams themselves for requests they make, bloating the components with responsibility that made it more difficult to test. The changes here introduce the following mediators and services for a clear separation of concerns and abstraction (ordered from least to most abstract):
These services greatly simplify making RSocket requests and observing RSocket streams, while also providing support for any route.
Event Visitors & Event Handlers
To offload the responsibility of event handling from components and services, the Visitor pattern was implemented for both public and private event objects. Instead of having components or services implement event handling, they can instead delegate this work to a visitor object using the event object's new
accept
method. Based on the visitor passed, the event is handled according to its event type, and whether it was successful or unsuccessful. Visitors currently utilize various handlers to delegate event processing. This pattern allows new visitors to be introduced, as well as new handlers, without changing existing functionality. Currently, we have the Group Visitor using the following handlers:Component Simplification
For the most part, components now thankfully do very little. They can simply define a route, pass it to a mediator or service, and observe the status of a stream or request through that mediator/service and update the view accordingly.
Other Changes
Several other changes have been made:
Additional Info / Concerns
RSocketJS has recently been considered to be "maintained but not under active development" by one of its most (and likely only) active contributors (see here). It may be time to consider alternative solutions to RSocket for both frontend and backend services. WebTransport seems to be the most similar, but it has limited availability in browsers at the moment.