@cortexql/messaging
Version:
An extension for Messaging implementation on CortexQL based on Apollo GraphQL Subscription Redis Adapter
18 lines (17 loc) • 787 B
TypeScript
import { BaseContext } from '@cortexql/core';
import { RedisPubSub } from 'graphql-redis-subscriptions';
export interface Subscription<T> extends AsyncIterableIterator<T> {
id: number;
unsubscribe(): Promise<void>;
}
export declare class MessagingService<C extends BaseContext> {
protected context: C;
constructor(context: C);
clientPromise: Promise<RedisPubSub>;
protected destroyHandler: any;
connect(): Promise<RedisPubSub>;
disconnect(): Promise<void>;
publish<T extends any = any>(name: string, payload: T): Promise<void>;
subscribe<T extends any = any>(name: string, onMessage: (payload: T) => any, options?: Object): Promise<() => Promise<void>>;
asyncIterator<T extends any = any>(name: string | string[]): AsyncIterableIterator<T>;
}