MCPcopy Create free account
hub / github.com/subquery/subql / createWorkerHost

Function createWorkerHost

packages/node-core/src/indexer/worker/worker.ts:136–167  ·  view source on GitHub ↗
(extraWorkerFns: (keyof T)[], extraHostFns: H)

Source from the content-addressed store, hash-verified

134];
135
136export function createWorkerHost<
137 T extends AsyncMethods,
138 H extends AsyncMethods & {initWorker: (height?: number) => Promise<void>},
139 ApiConnection /* ApiPromiseConnection*/,
140 DS extends BaseDataSource = BaseDataSource,
141>(extraWorkerFns: (keyof T)[], extraHostFns: H): WorkerHost<DefaultWorkerFunctions<ApiConnection, DS> & T> {
142 // Register these functions to be exposed to worker host
143 return WorkerHost.create<DefaultWorkerFunctions<ApiConnection, DS> & T, IBaseIndexerWorker & H>(
144 [
145 // Have this first to not override the default functions
146 ...extraWorkerFns,
147 ...hostStoreKeys,
148 ...hostCacheKeys,
149 ...hostDynamicDsKeys,
150 ...hostUnfinalizedBlocksKeys,
151 ...hostMonitorKeys,
152 ...hostConnectionPoolStateKeys,
153 ],
154 {
155 // Have this first to not override the default functions
156 ...extraHostFns,
157 fetchBlock,
158 processBlock,
159 numFetchedBlocks,
160 numFetchingBlocks,
161 getStatus,
162 getMemoryLeft,
163 abortFetching,
164 },
165 logger
166 );
167}
168
169export type TerminateableWorker<T extends IBaseIndexerWorker> = T & {terminate: () => Promise<number>};
170

Callers 1

worker.tsFile · 0.90

Calls 1

createMethod · 0.45

Tested by

no test coverage detected