@numaproj/numaflow-js - v0.0.0-alpha.4
    Preparing search index...

    Namespace reduce

    Reduce namespace for aggregating messages by key over time windows.

    Reduce operations aggregate multiple messages that share the same key within a time window. This is essential for:

    • Computing aggregates (sum, count, average)
    • Grouping related events
    • Time-windowed analytics
    import { reduce } from '@numaproj/numaflow-js';

    const server = new reduce.AsyncServer(async (keys, datums, metadata) => {
    let sum = 0;
    let count = 0;

    for await (const datum of datums) {
    const value = parseInt(datum.value.toString());
    sum += value;
    count++;
    }

    return [new reduce.Message(Buffer.from(JSON.stringify({
    keys,
    sum,
    count,
    window: metadata.intervalWindow
    })))];
    });

    server.start();

    Classes

    AsyncServer
    Message

    Interfaces

    Datum
    IntervalWindow
    MessageOptions
    Metadata

    Type Aliases

    Callback