BatchMap namespace for batch processing of messages.
BatchMap processes multiple messages together in a batch, which can be more efficient than processing one at a time. Use cases include:
import { batchmap } from '@numaproj/numaflow-js';const server = new batchmap.AsyncServer(async (datums) => { const responses: batchmap.Response[] = []; // Collect all messages const batch: batchmap.Datum[] = []; for await (const datum of datums) { batch.push(datum); } // Process batch and create responses for (const datum of batch) { const response = batchmap.Response.fromId(datum.id); response.append({ value: Buffer.from('processed'), keys: datum.keys }); responses.push(response); } return responses;});server.start(); Copy
import { batchmap } from '@numaproj/numaflow-js';const server = new batchmap.AsyncServer(async (datums) => { const responses: batchmap.Response[] = []; // Collect all messages const batch: batchmap.Datum[] = []; for await (const datum of datums) { batch.push(datum); } // Process batch and create responses for (const datum of batch) { const response = batchmap.Response.fromId(datum.id); response.append({ value: Buffer.from('processed'), keys: datum.keys }); responses.push(response); } return responses;});server.start();
BatchMap namespace for batch processing of messages.
BatchMap processes multiple messages together in a batch, which can be more efficient than processing one at a time. Use cases include:
Example