Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-4720

Add KStream.peek(ForeachAction<K,V>)

    XMLWordPrintableJSON

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.10.1.1
    • Fix Version/s: 0.11.0.0
    • Component/s: streams
    • Labels:

      Description

      Java's Stream provides a handy peek method that observes elements in the stream without transforming or filtering them. While you can emulate this functionality with either a filter or map, peek provides potentially useful semantic information (doesn't modify the stream) and is much more concise.

      Example usage: using Dropwizard Metrics to provide event counters

      KStream<Integer, String> s = ...;
      s.map(this::mungeData)
       .peek((i, s) -> metrics.noteMungedEvent(i, s))
       .filter(this::hadProcessingError)
       .print();
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                stevenschlansker Steven Schlansker
                Reporter:
                stevenschlansker Steven Schlansker
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: