@ceil-dev/redis-portal
v0.0.2
Published
Create Portal with Redis Ether
Readme
Redis Portal Library
Library for using Portals with Redis ether
Table of Contents
Overview
Connect multiple node processes via Redis with Portals
Installation
npm install @ceil-dev/redis-portalExample
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);License
This project is licensed under the MIT License - see the LICENSE file for details.
