share / share/sharedb

Idea: Protocol plugins, client/server capability handshake

Open
#337 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
6.5k
Forks
456
Avg merge
1d 5h
Merged PRs (30d)
5

Description

These are some of my thoughts around enabling more extensibility of ShareDB and more rapid development of new ideas. I'm hoping to find some time in the next month or two to write a more fleshed out spec, but in the meantime, comments and more ideas are welcome!

ShareDB message protocol plugins

Over the past couple years, there have been new features that require extending the ShareDB message protocol with different request.a "actions":

  • fetchSnapshotByTimestamp
  • Presence, still in progress

These are handled in large switch statements:

I've been thinking it would be good to implement a framework for message protocol plugins, and refactor more optional features like queries, fetchSnapshotByTimestamp, and presence into plugins. This has some nice advantages:

  1. ShareDB users could choose exactly what features they want, keeping code and bundle sizes smaller.
  2. We can develop new protocol-level features more rapidly as independent plugins, compared to developing them in ShareDB core. They can also be independently semver'd.
  3. ShareDB users could author their own protocol plugins without needing to touch ShareDB core.

One of the requirements to accomplishing this is that clients and servers need to be able to do some sort of capability handshake, so they can agree on what protocol plugins to use for the session and at what versions.

Client/server capability handshake

I haven't put much thought into this yet. It could work like a simpler version of a TLS handshake. It would need to include at least:

  • Capability names
  • Capability versions

Potential use cases for a capability handshake:

  • ShareDB message protocol plugins
  • Making it easier to do major semver updates to ShareDB core
  • Negotiating a default OT type or supported OT types in general: https://github.com/share/sharedb/issues/284
  • Custom application-specific capabilities defined by ShareDB users

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the switch statements in lib/agent.js and lib/client/connection.js, along with the related discussion in issue 284. The issue currently proposes protocol plugins and a capability handshake but does not define an implementation-ready scope or completion criteria; a fleshed-out specification would be needed before coding can begin.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend-api-design, distributed-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.