Files
Nathan Shively-Sanders 91ed2323be Make dynamodb-lock-client config types more accurate (#64207)
The config type's dynamodb property doesn't *actually* have to be an AWS
DynamoDB object. It accepts anything with delete/get/put methods.

This is important for DT because aws-sdk@2 uses so much memory that it
overwhelms its testing infrastructure, so it's helpful to remove
dependencies on aws-sdk@2.
2023-02-02 16:15:15 -08:00

51 lines
1.5 KiB
TypeScript

// Type definitions for dynamodb-lock-client 0.7
// Project: https://github.com/tristanls/dynamodb-lock-client#readme
// Definitions by: RyoshiKayo <https://github.com/RyoshiKayo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
import { EventEmitter } from "events";
export interface Lock extends EventEmitter {
release(callback: (error: Error) => void): void;
fencingToken: number;
}
interface GenericConfig {
dynamodb: {
delete: (...args: any[]) => any;
get: (...args: any[]) => any;
put: (...args: any[]) => any;
};
lockTable: string;
partitionKey: string;
sortKey?: string | undefined;
owner?: string | undefined;
}
export interface FailClosedConfig extends GenericConfig {
acquirePeriodMs: number;
}
export interface FailOpenConfig extends GenericConfig {
heartbeatPeriodMs?: number | undefined;
leaseDurationMs: number;
trustLocalTime?: boolean | undefined;
}
export class LockClient<PartitionTableKeyType extends string | number> {
acquireLock(id: PartitionTableKeyType, callback: (error: Error, lock: Lock) => void): void;
}
export class FailClosed<PartitionTableKeyType extends string | number> extends LockClient<PartitionTableKeyType> {
constructor(config: FailClosedConfig);
}
export class FailOpen<PartitionTableKeyType extends string | number> extends LockClient<PartitionTableKeyType> {
constructor(config: FailOpenConfig);
}
// Disabled automatic exporting
export {};