Skip to content

Commit d681865

Browse files
committed
docs: streamline features section and remove redundant explanations in README
1 parent bfe8280 commit d681865

File tree

1 file changed

+3
-64
lines changed

1 file changed

+3
-64
lines changed

β€Žpackages/socket.io-adapter/README.mdβ€Ž

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@ Redis-powered Socket.IO adapter for NestJS
1818

1919
## Features
2020

21-
- **Horizontal scaling**: Connect clients to any server instance
22-
- **Redis pub/sub**: Automatic event distribution across instances
23-
- **Lifecycle management**: Redis connections are managed automatically
24-
- **Works with existing connections**: Integrates seamlessly with `@nestjs-redis/client`
25-
- **Type-safe**: Full TypeScript support
26-
- **Production-ready**: Built on the official Socket.IO Redis adapter
21+
- Horizontal scaling with Redis pub/sub
22+
- Works with existing `@nestjs-redis/client` connections
23+
- Type-safe, production-ready
2724

2825
## Installation
2926

@@ -41,8 +38,6 @@ npm install @nestjs-redis/socket.io-adapter redis
4138

4239
## Quick Start
4340

44-
### Setup with existing Redis connection (Recommended)
45-
4641
```typescript
4742
// app.module.ts
4843
import { Module } from '@nestjs/common';
@@ -107,62 +102,6 @@ async function bootstrap() {
107102
}
108103
```
109104

110-
## The Problem
111-
112-
When scaling your NestJS application horizontally with multiple instances, WebSocket connections become a challenge. By default, Socket.IO connections are tied to a single server instance, which means:
113-
114-
- Events sent from one server instance won't reach clients connected to other instances
115-
- Real-time features break when users connect to different servers
116-
- Load balancing becomes complex as you need sticky sessions
117-
118-
## The Solution
119-
120-
This package provides a Redis-backed Socket.IO adapter that uses Redis pub/sub to synchronize events across all server instances. When a server emits an event, it's published to Redis and distributed to all other server instances, ensuring all clients receive the event regardless of which server they're connected to.
121-
122-
## How It Works
123-
124-
1. **Redis Pub/Sub**: The adapter creates two Redis connections - one for publishing and one for subscribing
125-
2. **Event Distribution**: When a server emits an event, it's published to a Redis channel
126-
3. **Cross-Instance Delivery**: All server instances subscribe to the same channels and forward events to their connected clients
127-
4. **Automatic Management**: Connection lifecycle is handled automatically by the adapter
128-
129-
## API
130-
131-
### `setupRedisAdapter(app, redisToken?)`
132-
133-
Sets up the Redis adapter for the NestJS application.
134-
135-
- `app`: NestJS application instance
136-
- `redisToken` (optional): Redis connection name (defaults to the default connection)
137-
138-
### `RedisIoAdapter`
139-
140-
The underlying Socket.IO adapter class that handles Redis connections.
141-
142-
## Architecture
143-
144-
```
145-
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
146-
β”‚ Server 1 β”‚ β”‚ Server 2 β”‚ β”‚ Server 3 β”‚
147-
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β” β”‚
148-
β”‚ β”‚Client β”‚ β”‚ β”‚ β”‚Client β”‚ β”‚ β”‚ β”‚Client β”‚ β”‚
149-
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
150-
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
151-
β”‚ β”‚ β”‚
152-
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
153-
β”‚
154-
β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”
155-
β”‚ Redis β”‚
156-
β”‚ Pub/Sub β”‚
157-
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
158-
```
159-
160-
## Learn More
161-
162-
- [NestJS WebSocket Adapter Documentation](https://docs.nestjs.com/websockets/adapter)
163-
- [Socket.IO Redis Adapter](https://socket.io/docs/v4/redis-adapter/)
164-
- [Redis Pub/Sub](https://redis.io/docs/manual/pubsub/)
165-
166105
## Links
167106

168107
- Root repo: [CSenshi/nestjs-redis](https://github.com/CSenshi/nestjs-redis)

0 commit comments

Comments
Β (0)