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: Add pipeline support for batching multiple publish calls #630

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jgillick
Copy link

@jgillick jgillick commented Jul 30, 2024

If a large number of publish calls need to be made, they call all be batched into a single HTTP request to redis with a pipeline.

This PR attempts to keep to keep the familiar redis pipelining API while supporting the PubSub config and serializer.

Basic Example

If you have a list to publish:

const pubSub = new RedisPubSub({ ... });

// Create pipeline
const pipeline = pubSub.pipeline();

[1,2,3,4,5,6].forEach((id) => pipeline.publish('Test', {id}))

// Execute the pipeline to redis
await pipeline.exec();

Chainable calls

If you have a specific number of publish calls to make at the same time:

const pubSub = new RedisPubSub({ ... });
await pubSub
  .pipeline()
  .publish('Test1', {})
  .publish('Test2', {})
  .publish('Test3', {})
  .exec();

@jgillick jgillick changed the title Add pipeline support for batching multiple publish calls feat: Add pipeline support for batching multiple publish calls Jul 30, 2024
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