@hotmeshio/hotmesh
Version:
Serverless Workflow
31 lines (30 loc) • 1.59 kB
TypeScript
import { StringAnyType } from '../../types';
import { ProviderClass, ProviderNativeClient, ProviderOptions } from '../../types/provider';
import { ILogger } from '../logger';
/**
* Abstract class for creating connections to different backend providers.
* All implementations should extend this class and implement
* the following steps:
*
* 1) Add the provider to ./providers/<name>.ts
* 2) Update ./factory.ts to reference the provider
* 3) Register the tag with the `Provider` type in ./types/provider.ts.
* 4) Create the specific provider type file at ./types/<name>.ts
* 5) Update ./modules/utils.ts (identifyProvider) with logic to resolve the provider by inspecting the class/import
*/
declare abstract class AbstractConnection<PClass, POptions> {
static logger: ILogger;
static disconnecting: boolean;
protected connection: any | null;
protected static instances: Map<string, AbstractConnection<ProviderClass, ProviderOptions>>;
protected id: string | null;
protected abstract defaultOptions: any;
protected abstract createConnection(client: PClass, options: POptions, config?: StringAnyType): Promise<any>;
abstract getClient(): ProviderNativeClient;
disconnect(): Promise<void>;
protected abstract closeConnection(connection: any): Promise<void>;
static connect<T extends AbstractConnection<ProviderClass, ProviderOptions>>(this: new () => T, id: string, client: ProviderClass, options?: ProviderOptions, //user
config?: StringAnyType): Promise<T>;
static disconnectAll(): Promise<void>;
}
export { AbstractConnection };