Beispiel #1
0
 def on_stream_event_out(self, tp: TP, offset: int, stream: StreamT,
                         event: EventT) -> None:
     """Call when stream is finished handling event."""
     has_active_test = getattr(stream, 'current_test', None)
     if has_active_test:
         stream.current_test = None
         current_test_stack.pop()
Beispiel #2
0
 def on_stream_event_in(self, tp: TP, offset: int, stream: StreamT,
                        event: EventT) -> None:
     """Call when stream starts processing event."""
     test = TestExecution.from_headers(event.headers)
     if test is not None:
         stream.current_test = test
         current_test_stack.push_without_automatic_cleanup(test)
Beispiel #3
0
async def process_stream(stream: StreamT) -> AsyncGenerator:
    """Process incoming events from the source topics."""
    async for event in stream.events():
        # The timestamp (key) comes from the "time" field in the stream
        timestamp = event.value["time"]
        # Get the current value for this key
        record = table[timestamp].value()
        # Append the new value
        record.append({f"{event.message.topic}.value": event.value["value0"]})
        # upsert table
        table[timestamp] = record

        yield event