Skip to content
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

feat: handle binary buffers with messageBuffer #3

Merged
merged 1 commit into from
May 17, 2024

Conversation

Julien-R44
Copy link
Collaborator

The issue is well described here: Julien-R44/bentocache#19

Basically: when using a custom encoder which returns a buffer with binary data, then it will not work. because the message event emitted by ioredis automatically converts buffers

When dealing with binary data then ioredis recommends using the messageBuffer event: https://github.com/redis/ioredis?tab=readme-ov-file#pubsub

image


Suggested solution: when we create our bus with the redis transport, we can now pass the useMessageBuffer option which will make the bus listen on the messageBuffer event rather than message.

const manager = new BusManager({
  transports: {
    redis: {
      transport: redis(
        {
          useMessageBuffer: true, // here
          host: 'localhost',
          port: 6379,
        },
        new BinaryEncoder() // pass our custom encoder
      ),
    },
  },
})

Breaking Change: The encoder signature has changed. The decode function now accepts a string or a Buffer. I think we can release that this in a minor release, since i think nobody has created a custom encoder yet.

@Julien-R44 Julien-R44 merged commit 16df254 into main May 17, 2024
10 checks passed
@Julien-R44 Julien-R44 deleted the feat/binary-buffer branch May 17, 2024 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant