yjs / y-websocket

Websocket Connector for Yjs
https://docs.yjs.dev/ecosystem/connection-provider/y-websocket
MIT License
499 stars 258 forks source link

Let caller of setupWSConnection create their own callback function #61

Closed canadaduane closed 2 years ago

canadaduane commented 3 years ago

I proposed the following question in #60:

Would it make sense to consider a "plugin" style of configuration for callbacks?

This PR represents an attempt at this, by making callbackHandler a parameter that can be passed in to setupWSConnection. If none is provided, but env vars such as CALLBACK_URL etc. are given, then the "default callbackHandler" is used, as before.

Would this be a good way forward?

Huly®: YJS-763

canadaduane commented 3 years ago

Also, a nice additional benefit of this system is that the callback need not send out to an external URL--it could just connect directly to a DB and store the results.

dmonad commented 3 years ago

Hey @canadaduane, I like the change.

The change doesn't look dangerous. But could you please test if the server is still running when:

I'd be happy to merge and publish a new release after you tested the above cases. Thanks!

Unfortunately, the server doesn't have any tests yet. Would be nice to change that at some point.

canadaduane commented 3 years ago

Sure! I did lightly test a couple of these cases, but I will be more thorough & get back to you.