subsquid-stream-store
v1.0.0
Published
Stream store for Subsquid
Maintainers
Readme
subsquid-stream-store
This package allows you to stream decoded data from a squid to a message queue.
Installation
# (not real package name)
npm install @subsquid/stream-storeUsage
import { StreamStore, RabbitMQAdaptor } from "@subsquid/stream-store";
const streamStore = new StreamStore(new RabbitMQAdaptor("usdc-transfers"));
processor.run(streamStore, (ctx) => {
ctx.store.publish({ data: /* Your decoded data */ });
});For each adaptor, you need a different set of environment variables.
# RabbitMQ
RABBITMQ_URI=amqp://user:password@localhost:5672
# Kafka
KAFKA_BROKER_URI=localhost:29092
# Redis
REDIS_HOST=localhost
REDIS_PORT=6379Available Adaptors
Examples
You can check the usage examples in the examples folder.
Running examples
First, build the stream store package:
npm install
npm run buildThen, build the examples package:
cd examples/
npm install
npm run buildCreate .env file in the examples folder with the environment variables.
cp .env.example .envStart the services:
docker compose upIn two separate terminals, run the producer and consumer:
# Terminal 1
npm run examples:producer
# Terminal 2
npm run examples:consumer