Comments (3)
We're (ab)using the op source to pass extra metadata to the server, since the source can technically be a JSON object:
doc.submitOp(op, {
source: 'user', // nest the source if it matters to you
options: {...}, // other stuff you want on the server
})
Of course this isn't the most semantic thing to do.
Could definitely discuss a PR that passes more information. Adding the data should be relatively simple; I deliberately added an "extra" .x
field to the message, which more stuff could be added to.
The main wrinkle is dealing with op composition: if you're attaching information to a particular op, we'll probably need to force op composition to be turned off.
from sharedb.
The main wrinkle is dealing with op composition: if you're attaching information to a particular op, we'll probably need to force op composition to be turned off.
Can you say more about this?
In our case, we are passing a signed authorization token, without which the op should not occur.
So, I think you are correct. We need to treat each option as a unique, separately authorized request. We would not be able to apply the authorization from one op to another (because it contains a commitment to the particular op).
Where and how does composition happen in sharedb?
from sharedb.
We would not be able to apply the authorization from one op to another (because it contains a commitment to the particular op).
To be honest this setup sounds a little odd to me. I'm not sure I understand why you'd authenticate each op individually instead of just authenticating the connection?
Your app architecture aside, ShareDB will by default try to compose — that is, merge — ops that are submitted in quick succession (more formally, while waiting for the server acknowledgement of a currently in-flight op). That means that — by default — an op cannot be considered as a discrete unit, since it might be coalesced onto another op. This all happens on the client.
This behaviour can be manually disabled with the doc.preventCompose
flag, with the obvious performance penalty of increased network traffic (although it sounds like in your particular case this is expected), and potentially increased DB storage, network and CPU load (due to having more ops stored).
The previously mentioned submitSource
flag works around this by only allowing composing of ops with identical sources, which lets ops compose if the source is equal, allowing some performance gains so long as source
isn't unique per-op.
from sharedb.
Related Issues (20)
- Question client doc handleOp not debounce ?
- `TypeError Cannot read properties of null (reading 'callback')` when receiving subscribe response with no inflight subscribe HOT 4
- Feature suggestion: type accessors HOT 3
- Q: How multiple `Doc`s guarantee transactions? HOT 2
- Collaborative text field using react with debounce HOT 3
- How can I synchronize my article titles? HOT 6
- Avoid committing no-ops
- Feature Request: Support for Custom Type Projections in ShareDB HOT 3
- API Support for Presence Notifications HOT 6
- How do I implement custom messages, just like websockets HOT 2
- Consider Partysocket for Examples
- Access Control / Permissions HOT 2
- Example Proposal: Comments
- Messages artificially delayed when running `Backend` in the browser HOT 1
- how to reload/refresh ShareDB document? HOT 6
- Invalid op submitted. Op version newer than current snapshot HOT 4
- failed process file : failed send RangeError: Invalid string length HOT 4
- The doc links are broken
- [Bug Report] Server-Side Data Inconsistencies When Rapidly Creating Nodes in ShareDB HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sharedb.