You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to add in the ability to swap in a custom msgpack library to use. I'm making a proposal first before opening a PR just to see if there's support. This would somewhat mirror the existing capacity to bring your own packet parser to socket.io.
My proposal for the change would be to add a new key/value to RedisAdapterOptions of something like:
interface MsgpackInterface {
decode: (data: any) => any;
encode: (data: any) => any;
}
interface RedisAdapterOptions {
// other options
/**
* MessagePack library to use for marshaling and un-marshalling data out of Redis.
*
* @default notepack.io
*/
msgpack?: MsgpackInterface;
}
and then in the RedisAdapter constructor, have something like this.msgpack = opts.msgpack || msgpack, and then any future call to msgpack in the class would be replaced with this.msgpack. I've loosely tested this within my own application and haven't seen anything break, but I may be missing something on how this is used.
For the motivation for this change, this library currently uses the notepack.io library to handle encoding/decoding messages into/out of redis. In benchmarking our application, we are finding that msgpackr library would give us a decent speed-up for the sorts of payloads we have (We also already use it in a number of other places in our stack):
This PR adds a new parser option to the adapter constructor to allow
setting a custom parser to use, defaulting to using notepack.io. This
would allow someone to use a different msgpack library if they wanted,
or even an entirely different protocol altogether (e.g. protobuf).
Related:
- #462
- #469
I'd like to add in the ability to swap in a custom
msgpack
library to use. I'm making a proposal first before opening a PR just to see if there's support. This would somewhat mirror the existing capacity to bring your own packet parser to socket.io.My proposal for the change would be to add a new key/value to
RedisAdapterOptions
of something like:and then in the
RedisAdapter
constructor, have something likethis.msgpack = opts.msgpack || msgpack
, and then any future call tomsgpack
in the class would be replaced withthis.msgpack
. I've loosely tested this within my own application and haven't seen anything break, but I may be missing something on how this is used.I'd make a similar change for the
@socket.io/redis-emitter
library as well.For the motivation for this change, this library currently uses the
notepack.io
library to handle encoding/decoding messages into/out of redis. In benchmarking our application, we are finding thatmsgpackr
library would give us a decent speed-up for the sorts of payloads we have (We also already use it in a number of other places in our stack):As such, I'd like to have the ability to provide my own msgpack implementation to use for the adapter.
The text was updated successfully, but these errors were encountered: