Library for using Portals with Redis ether
Connect multiple node processes via Redis with Portals
npm install @ceil-dev/redis-portal
import { createClient } from '@node-redis/client';
import { createRedisPortal, microEnv } from '@ceil-dev/redis-portal';
const run = async () => {
// Assuming you have a redis server running on port 6379
const port = 6379;
const pubClient = createClient({
url: 'redis://localhost:' + port, // Update with your Redis URL
});
pubClient.on('connect', () => {
console.log('Connected to Redis (pub) on port', port);
});
pubClient.on('error', (err) => {
console.error('Redis Client Error:', err);
});
pubClient.connect();
const subClient = createClient({
url: 'redis://localhost:' + port, // Update with your Redis URL
});
subClient.on('connect', () => {
console.log('Connected to Redis (sub) on port', port);
});
subClient.on('error', (err) => {
console.error('Redis Client Error:', err);
});
subClient.connect();
const portal = createRedisPortal({
pubClient,
subClient,
env: microEnv({ hello: 'world' }, { id: 'envA' }),
});
portal('open');
// Now you can enter this portal "envA" from another local process
};
run().catch(console.error);
This project is licensed under the MIT License - see the LICENSE file for details.