Skip to content

0.1.0

Compare
Choose a tag to compare
@gabrielmbmb gabrielmbmb released this 09 Apr 11:57
· 16 commits to main since this release
aa0bf34

✨ Features

  • Better data extraction from message:
    • Extract data from the value of the message using FromValue[...]
    • Extract data from the key of the message using FromKey[...]
    • Extract data from the headers of the message using FromHeader[...]
    from pydantic import BaseModel
    
    from kaflow import FromHeader, FromKey, FromValue, Json, Kaflow
    
    
    class Stock(BaseModel):
        name: str
        price: float
    
    
    class Key(BaseModel):
        key: str
    
    
    class Header1(BaseModel):
        header: str
    
    
    class Header2(BaseModel):
        header: str
    
    
    app = Kaflow(client_id="kaflow", brokers="localhost:9092")
    
    
    @app.consume(topic="stock")
    async def consume_stock(
        value: FromValue[Json[Stock]],
        key: FromKey[Json[Key]],
        header_1: FromHeader[Json[Header1]],
        header_2: FromHeader[Json[Header2]],
    ) -> None:
        print("value", value)
        print("key", key)
        print("header 1", header_1)
        print("header 2", header_2)
    
    
    app.run()
  • Add String serializer
  • Add aiokafka.{AIOKafkaProducer, AIOKafkaConsumer} parameters to Kaflow.__init__ method