// Import types import CollectionOpts from '../types/CollectionOpts'; // Import constants import DEFAULT_LOCK_TTL_MS from '../constants/DEFAULT_LOCK_TTL_MS'; /** * Helper for initializing the lock collection. * For unifying construction of lock-collections (for testing). * @author Benedikt Arnarsson * @param ttlMS the time to live (in ms) of the locks in the collection. * @returns the options used to construct a collections corresponding lock-collection. */ const getLockCollectionOpts = (ttlMS?: number): CollectionOpts => { return { expireAfterSeconds: ( ttlMS ? ttlMS / 1000 : DEFAULT_LOCK_TTL_MS / 1000 ), uniqueIndexKey: 'id', indexKeys: [ 'serverId', ], }; }; export default getLockCollectionOpts;