-
Notifications
You must be signed in to change notification settings - Fork 452
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
How to pass options through to server? #603
Comments
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" 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? |
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 The previously mentioned |
We have an operation, for which we need to pass additional options through to the server.
However, in doc.js Doc.prototype.submitOp, the only option value that survives to the server's submit is [source].
Is there some other way to pass that information?
Or would it be welcome if we updated that bit of code to allow the submitOp caller to pass options through to the server?
The text was updated successfully, but these errors were encountered: