@hotmeshio/hotmesh
Version:
Serverless Workflow
26 lines (25 loc) • 1.05 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.search = void 0;
const common_1 = require("./common");
/**
* Returns a search session handle for interacting with the workflow's HASH storage.
* @returns {Promise<Search>} A search session for workflow data.
*/
async function search() {
const store = common_1.asyncLocalStorage.getStore();
const workflowId = store.get('workflowId');
const workflowDimension = store.get('workflowDimension') ?? '';
const workflowTopic = store.get('workflowTopic');
const connection = store.get('connection');
const namespace = store.get('namespace');
const COUNTER = store.get('counter');
const execIndex = COUNTER.counter = COUNTER.counter + 1;
const hotMeshClient = await common_1.WorkerService.getHotMesh(workflowTopic, {
connection,
namespace,
});
const searchSessionId = `-search${workflowDimension}-${execIndex}`;
return new common_1.Search(workflowId, hotMeshClient, searchSessionId);
}
exports.search = search;
;