metricq / metricq-python

🐍 The MetricQ Python interface
https://metricq.github.io/metricq-python/
BSD 3-Clause "New" or "Revised" License
18 stars 7 forks source link

Feature Drain and Subscriber #107

Closed Daddelhai closed 3 years ago

Daddelhai commented 3 years ago

Fixes #12

Implements Drain and Subscriber

Daddelhai commented 3 years ago

Works now like

    async with Subscriber(
        "example", "amqp://admin:admin@localhost", metrics=["dummy.source"]
    ) as subscription:

        await asyncio.sleep(10)

        counter = 0
        async with subscription.drain() as drain:
            async for metric, time, value in drain:
                print(str(counter) + " " + str(time) + " " + str(value))
                counter += 1

        print("done: " + str(counter) + " data points received")

How do you like it?

phijor commented 3 years ago

Two general comments: