mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
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.
51 lines
1.5 KiB
TypeScript
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 {};
|