Skip to content

Add syncPolicy callback for per-document authorization#350

Open
max-dekock wants to merge 3 commits into
automerge:mainfrom
max-dekock:sync-policy
Open

Add syncPolicy callback for per-document authorization#350
max-dekock wants to merge 3 commits into
automerge:mainfrom
max-dekock:sync-policy

Conversation

@max-dekock

Copy link
Copy Markdown

This PR adds a syncPolicy callback to the repo configuration. It will be called whenever a sync message is received from a peer, and if it returns false, syncing will be blocked, and the repo will respond with a doc-unavailable message.

Currently, if sharePolicy returns true, the repo will still send sync messages to peers even if syncPolicy would return false. If this is undesirable, another possibility is to only share if syncPolicy and sharePolicy both return true.


const documentId = message.documentId
const senderId = message.senderId
const okToSync = await this.repo.syncPolicy(senderId, documentId)

@twop twop Jun 9, 2024

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

was casually observing Discord and took a look at the PR, hence pardon my intrusion, just wanted to mention that await somePromise will always put a new event into the event loop at the very end, thus even an innocent no-op (like async () => true) can create a lot of latency if the event loop is busy/saturated. So it is possible that it might be better to make it optional and thus not awaiting as the default behavior.

@pvh pvh force-pushed the main branch 2 times, most recently from e61f8e3 to d3d1a7d Compare July 26, 2024 20:13
@pvh pvh force-pushed the main branch 3 times, most recently from b5b124c to 12ae986 Compare April 3, 2025 02:10
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.

2 participants