import { RedisPubSubEventBusAdapter } from "@daiso-tech/core/event-bus/adapters";
import { Serde } from "@daiso-tech/core/serde";
import { SuperJsonSerdeAdapter } from "@daiso-tech/core/serde/adapters"
import Redis from "ioredis";
const dispatcherClient = new Redis("YOUR_REDIS_CONNECTION_STRING");
const listenerClient = new Redis("YOUR_REDIS_CONNECTION_STRING");
const serde = new Serde(new SuperJsonSerdeAdapter());
const eventBusAdapter = new RedisPubSubEventBusAdapter({
dispatcherClient,
listenerClient,
serde,
});
The addListener
method is used for adding listener
for certain eventName
.
The removeListener
method is used for removing listener
for certain eventName
.
To utilize the
RedisPubSubEventBusAdapter
, you must install the"ioredis"
package and supply aISerde<string>
, with aSuperJsonSerdeAdapter
.IMPORT_PATH:
"@daiso-tech/core/event-bus/adapters"