Skip to content

Commit

Permalink
chore: accept timeout option for createMapeoClient() (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
achou11 authored Feb 1, 2024
1 parent d25dff5 commit 8dfca00
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,22 @@ const CLOSE = Symbol('close')

/**
* @param {import('./lib/sub-channel.js').MessagePortLike} messagePort
* @param {object} [opts]
* @param {number} [opts.timeout]
*
* @returns {MapeoClientApi}
*/
export function createMapeoClient(messagePort) {
export function createMapeoClient(messagePort, opts = {}) {
/** @type {Map<string, Promise<import('rpc-reflector/client.js').ClientApi<import('@mapeo/core/dist/mapeo-project.js').MapeoProject>>>} */
const projectClientPromises = new Map()

const managerChannel = new SubChannel(messagePort, MANAGER_CHANNEL_ID)
const mapeoRpcChannel = new SubChannel(messagePort, MAPEO_RPC_ID)

/** @type {import('rpc-reflector').ClientApi<import('@mapeo/core').MapeoManager>} */
const managerClient = createClient(managerChannel)
const managerClient = createClient(managerChannel, opts)
/** @type {import('rpc-reflector').ClientApi<import('./server.js').MapeoRpcApi>} */
const mapeoRpcClient = createClient(mapeoRpcChannel)
const mapeoRpcClient = createClient(mapeoRpcChannel, opts)

mapeoRpcChannel.start()
managerChannel.start()
Expand Down

0 comments on commit 8dfca00

Please sign in to comment.