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

Multiple collections share sockets and peers when replicationWebrtc is used for synchronization #5926

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

croatialu
Copy link
Contributor

This PR contains:

  • A NEW FEATURE

Describe the problem you have without this PR

#5925

@croatialu
Copy link
Contributor Author

You can experience the difference between before and after modification at this link

https://stackblitz.com/~/github.com/croatialu/rxdb-replication-webrtc

@croatialu
Copy link
Contributor Author

Solution: Use closure to save data such as peers and sockets, and then each replicationWebrtc will try its best to reuse existing peers and sockets

How to use:

  const creator = getConnectionHandlerSimplePeer({})
  //                        ^ create a creator
  Object.keys(database.collections).map(async (key) => {
    return replicateWebRTC({
      collection:
        database.collections[key as keyof typeof database.collections],
      connectionHandlerCreator: creator,
      //                           ^ use the creator
      topic: dbName,
      pull: {},
      push: {},
    })
  })

@pubkey
Copy link
Owner

pubkey commented Apr 24, 2024

Hi @croatialu
Code changes look ok but this breaks the CI, please check.
Also we need at least one test to check the correctness of the new behavior.

@croatialu
Copy link
Contributor Author

Hi @croatialu Code changes look ok but this breaks the CI, please check. Also we need at least one test to check the correctness of the new behavior.

Okay, I'll take care of it right away. Thanks for the reminder!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants