예제 #1
0
 async def proc(events):
     if batch_size == 1:
         async for action in events.records():
             assert action.key in keys
             await results.incr()
             await results.redis.incr(event_id(action.seq))
     else:
         async for batch in events.take(batch_size, within=0.1).records():
             assert len(batch) <= batch_size
             for action in batch:
                 assert action.key in keys
                 await results.incr()
                 await results.redis.incr(event_id(action.seq))
예제 #2
0
    async def proc(events):
        last_seen = {key: -1 for key in keys}

        if batch_size == 1:
            async for obj in events.records():
                assert obj.seq > last_seen[obj.key]
                last_seen[obj.key] = obj.seq
                await results.incr()
                await results.redis.incr(event_id(obj.seq))
        else:
            async for batch in events.take(batch_size, within=0.1).records():
                for obj in batch:
                    assert obj.seq > last_seen[obj.key]
                    last_seen[obj.key] = obj.seq
                    await results.incr()
                    await results.redis.incr(event_id(obj.seq))
예제 #3
0
 async def proc(events):
     async for action in events.records():
         await anyio.sleep(random.random())
         await results.incr()
         await results.redis.incr(event_id(action.seq))
예제 #4
0
 async def proc(events):
     async for obj in events.records():
         await results.incr()
         await results.redis.incr(event_id(obj.seq))
         if obj.seq == 10:
             raise ValueError("testing-user-error")
예제 #5
0
async def proc(events):
    results = Results(app.redis)
    async for obj in events.records():
        await results.incr()
        await results.redis.incr(event_id(obj.seq))
예제 #6
0
 async def proc(events):
     async for action in events.records():
         assert action.key in keys
         await results.incr()
         await results.redis.incr(event_id(action.seq))