Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GROUP-89 Improve RSocket Services & Event Handling #21

Merged
merged 15 commits into from
Mar 19, 2024

Conversation

makmn1
Copy link
Member

@makmn1 makmn1 commented Mar 19, 2024

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):

  • RSocket Request Factory
  • RSocket Request Mediator
  • RSocket Request Stream Mediator
  • RSocket Asynchronous Request Mediator
  • Event Stream

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:

  • Group Updated Handler (for group created or updated events)
  • Member Joined Handler
  • Member Left Handler

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:

  • Retry classes have been revamped to one Retry Service that can take different Retry Strategies
  • Group Manager Service has been restructured to move groups state to Groups Service. Also, sorting logic originally in Groups Service is now in a new Group Sorting Service
  • The Jasmine Marbles package has been removed in favor of RxJS' own provided test utilities
  • Most tests have been updated to rely less on mocking

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.

@makmn1 makmn1 added bug Something isn't working enhancement New feature or request labels Mar 19, 2024
@makmn1 makmn1 self-assigned this Mar 19, 2024
@makmn1 makmn1 merged commit 12f0393 into main Mar 19, 2024
3 checks passed
@makmn1 makmn1 deleted the GROUP-89-Fix-Loading-Issues branch March 19, 2024 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant