Collect previous events only.
Opened this issue · 0 comments
johny-b commented
Let's say we have an activity_id
and a batch_id
and want to fetch all events that happened to this batch.
Currently there's no clean way to do this, we might try e.g.:
async with GolemNode() as golem:
batch = golem.batch(batch_id, activity_id)
batch.start_collecting_events()
await asyncio.sleep(1)
print(batch.events)
and this is fine, except that in some rare cases single second might not be enough, and in other cases we wait too long.
Or we could:
async with GolemNode() as golem:
batch = golem.batch(batch_id, activity_id)
batch.start_collecting_events()
await batch.wait()
print(batch.events)
but this way we'll hang forever if the batch was not finished.
--> we need something like:
async with GolemNode() as golem:
batch = golem.batch(batch_id, activity_id)
await batch.fetch_past_events()
print(batch.events)
This shouldn't be hard.
Probably should be implemented on golem_core.low.yagna_event_collector.YagnaEventCollector
.