Skip to main content
Glama

mcp-google-sheets

memory-lock.ts1.14 kB
import { E_TIMEOUT, Mutex, MutexInterface, withTimeout } from 'async-mutex' const memoryLocks = new Map<string, MutexInterface>() export const memoryLock = { acquire: async (key: string, timeout?: number): Promise<ApLock> => { let lock = memoryLocks.get(key) if (!lock) { if (timeout) { lock = withTimeout(new Mutex(), timeout) } else { lock = new Mutex() } memoryLocks.set(key, lock) } const release = await lock.acquire() return { release: async () => { release() }, } }, isTimeoutError: (e: unknown): boolean => { return e === E_TIMEOUT }, runExclusive: async <T>({ key, fn }: RunExclusiveParams<T>): Promise<T> => { const lock = await memoryLock.acquire(key) try { return await fn() } finally { await lock.release() } }, } type RunExclusiveParams<T> = { key: string fn: () => Promise<T> } export type ApLock = { release(): Promise<unknown> }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/activepieces/activepieces'

If you have feedback or need assistance with the MCP directory API, please join our Discord server