UNPKG

fp-ts-pool

Version:
11 lines (10 loc) 663 B
import { Bracket as B } from "fp-ts-bracket"; import * as TE from "fp-ts/lib/TaskEither"; import { PoolOptions } from "tarn/dist/Pool"; export interface WithPoolOptions<R> extends Omit<PoolOptions<R>, "create" | "destroy" | "validate"> { create: () => TE.TaskEither<Error, R>; destroy: (client: R) => TE.TaskEither<Error, void>; validate?: (client: R) => TE.TaskEither<Error, boolean>; } export declare function withPool<R>({ create, destroy, validate, ...moreOptions }: WithPoolOptions<R>): <T>(fn: (acquire: () => B.Bracket<Error, R>) => TE.TaskEither<Error, T>) => TE.TaskEither<Error, T>; export type WithPool<R> = ReturnType<typeof withPool<R>>;