Skip to content

Commit

Permalink
pass specs through thread instead of redis
Browse files Browse the repository at this point in the history
  • Loading branch information
rjawesome committed May 16, 2024
1 parent 061bb60 commit 192f695
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
12 changes: 1 addition & 11 deletions src/controllers/cron/update_local_smartapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,17 +333,7 @@ async function updateSmartAPISpecs() {
const metakg = new MetaKG();
metakg.constructMetaKGSync(true, { predicates: predicatesInfo, smartapiSpecs: { hits: hits as any }, apiList });
global.metakg = metakg;

// write to the redis database
if (redisClient.clientEnabled) {
debug("Writing smartapi hits to redis");
try {
await redisClient.client.setTimeout(`bte:smartapi:specs`, JSON.stringify({ hits }));
debug("Wrote smartapi hits to redis");
} catch (e) {
debug(`Error writing smartapi hits to redis: ${e}`);
}
}
global.smartapi = { hits };
};

async function getAPIOverrides(data: { total?: number; hits: any }, overrides: SmartApiOverrides) {
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/threading/threadHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async function queueTaskToWorkers(pool: Piscina, taskInfo: TaskInfo, route: stri
const { traceparent, tracestate } = otelData;

const taskData: InnerTaskData = { req: taskInfo, route, traceparent, tracestate, port: toWorker };
taskData.req.data.options = {...taskData.req.data.options, metakg: global.metakg?.ops};
taskData.req.data.options = {...taskData.req.data.options, metakg: global.metakg?.ops, smartapi: global.smartapi};

// Propagate data between task runner and bull job
if (job) taskData.job = { jobId: job.id, queueName: job.queue.name };
Expand Down

0 comments on commit 192f695

Please sign in to comment.