Skip to content

Conversation

Totodore
Copy link
Owner

@Totodore Totodore commented Nov 5, 2024

Motivation

Transform the Adapter trait to return impl Future + Send so that it is possible to implement adapters with other systems (redis, mongo, ...).

Solution

  • The Adapter returns impl Future + Send for all the methods that may need to communicate remotely (e.g emit, emit_with_ack on the BroadcastOperators and SocketIo structs).
  • The base adapter logic has been moved to the socketioxide_core trait as well as some error types. So that new adapters only need to depends on socketioxide_core.
  • Packet and AckError implement Serialize in order to send them to remote nodes.
  • ParserError is now simply a wrapper around a Box<impl StdError> so that it is easy to impl serde on it. Therefore the DecodeError and EncodeError GAT have been removed.
  • A new adapter State GAT allow any Adapter implementors to share a common state between all adapters of a node. It can be useful to share a connection to a remote server (redis, mongo, ...).
  • A new AckStream GAT allow the adapter to merge a stream from the local node with a remote stream of acknowledgments.

Remaining questions/issues:

  • Find a solution to initialize each namespace. Currently namespaces are initialized through a spawned task. But this leads to failed tests and the user can't get the error if the initialization failed.

To do:

  • Update documentation on operators. Some socket methods are sync and local whereas the same method is async on BroadcastOperators.

@Totodore Totodore mentioned this pull request Nov 5, 2024
* Remove Sync bound on adapter error
* Add an AdapterCtr trait to keep state
Copy link

@github-advanced-security github-advanced-security bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clippy found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@Totodore Totodore mentioned this pull request Nov 21, 2024
* return broadcast ack count
* remove empty rooms
@Totodore Totodore mentioned this pull request Dec 20, 2024
3 tasks
@Totodore Totodore linked an issue Dec 21, 2024 that may be closed by this pull request
@Totodore
Copy link
Owner Author

This is already too big, I'm merging this on the branch feat-adapter-rework. We will make small other PRs to improve the async adapter interface if necessary.

@Totodore Totodore merged commit 3277650 into feat-adapter-rework Dec 24, 2024
14 checks passed
@Totodore Totodore deleted the async-adapter branch December 24, 2024 10:36
Totodore added a commit that referenced this pull request Jan 12, 2025
* feat(socketio): async adapter (#395)

* feat: improve `Adapter` error types for `broadcast` and `disconnect` methods (#408)

* feat(socketio/ns): improve `SocketEmitter` trait (#410)

* feat(core/adapter): pass filter to get_sids

* feat: add custom `Iterator` return for apply_opts fn

* chore(docs): add doc on async adapters (#411)

* feat(adapter): add a remote socket API (#412)

* feat(core): switch to a new type for server uid (#413)

* chore(deps): rm `__test_harness` && `tracing` feature flags.

* chore(deps): add fuzzing as cfg flag

* chore(ci): msrv

* chore(clippy): fix redundant import (#414)

* feat(core): improve local adapter perf (#415)

* test(e2e): provide e2e testing system for adapters (#422)

* test(e2e): provide e2e testing system for adapters

* fix(e2e/adapter): remove redis deps

* feat(socketio): check namespaces at insertion

* feat(redis): redis adapter crate (#402)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant