Skip to content

Conversation

@matanper
Copy link

Summary

Adds a new generic entry point that allows users to provide their own Publisher/Subscriber implementations, making the library compatible with any Redis-like client (Upstash Redis, Valkey, etc.).

Changes

  • New entry point: resumable-stream/generic - requires custom Publisher/Subscriber implementations
  • Comprehensive tests: 4 new tests covering basic usage, resumption, and error handling
  • Updated documentation: README now includes section on using custom Redis clients with example code
  • Package configuration: Added exports and TypeScript definitions for the generic module

Usage Example

import { createResumableStreamContext } from "resumable-stream/generic";
import type { Publisher, Subscriber } from "resumable-stream/generic";

// Create your custom adapters
const publisher: Publisher = {
  connect: async () => { /* ... */ },
  publish: async (channel, message) => { /* ... */ },
  set: async (key, value, options) => { /* ... */ },
  get: async (key) => { /* ... */ },
  incr: async (key) => { /* ... */ },
};

const subscriber: Subscriber = {
  connect: async () => { /* ... */ },
  subscribe: async (channel, callback) => { /* ... */ },
  unsubscribe: async (channel) => { /* ... */ },
};

const streamContext = createResumableStreamContext({
  waitUntil: null,
  publisher,
  subscriber,
});

- Add src/generic.ts with generic interface requiring custom Publisher/Subscriber
- Add comprehensive tests for generic interface (4 tests, all passing)
- Update package.json with generic module exports
- Update tsconfig.build.json to include generic.ts in build
- Update README.md with documentation for using custom Redis clients
- Support for Upstash Redis, Valkey, and other Redis-compatible clients
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