@anyq/core
v0.1.1
Published
Core interfaces and utilities for anyq - Universal Queue Library
Downloads
186
Maintainers
Readme
@anyq/core
Core interfaces and utilities for anyq - a Universal Message Queue Library.
Installation
npm install @anyq/coreOverview
This package provides the foundational types, interfaces, and utilities used by all anyq adapters:
- IProducer - Interface for publishing messages
- IConsumer - Interface for consuming messages
- IMessage - Standard message format across all adapters
- Middleware - Circuit breaker, retry with exponential backoff
- Serialization - JSON serializer with schema support
Usage
import {
IProducer,
IConsumer,
IMessage,
CircuitBreaker,
RetryWithBackoff,
JsonSerializer
} from '@anyq/core';Interfaces
IProducer
interface IProducer<T = unknown> {
publish(message: T, options?: PublishOptions): Promise<PublishResult>;
publishBatch(messages: T[], options?: PublishOptions): Promise<PublishResult[]>;
connect(): Promise<void>;
disconnect(): Promise<void>;
}IConsumer
interface IConsumer<T = unknown> {
subscribe(handler: MessageHandler<T>, options?: SubscribeOptions): Promise<void>;
unsubscribe(): Promise<void>;
connect(): Promise<void>;
disconnect(): Promise<void>;
}IMessage
interface IMessage<T = unknown> {
id: string;
data: T;
timestamp: Date;
headers?: Record<string, string>;
ack(): Promise<void>;
nack(requeue?: boolean): Promise<void>;
extend?(seconds: number): Promise<void>;
}Adapters
Use @anyq/core with these adapters:
- @anyq/memory - In-memory (testing)
- @anyq/redis-streams - Redis Streams
- @anyq/rabbitmq - RabbitMQ
- @anyq/sqs - AWS SQS
- @anyq/sns - AWS SNS
- @anyq/kafka - Apache Kafka
- @anyq/nats - NATS JetStream
- @anyq/google-pubsub - Google Pub/Sub
- @anyq/azure-servicebus - Azure Service Bus
License
MIT
