Skip to content

Split creating and consulting a Shard into different classes

Creating and consulting a Shard are two different operations that are always done separately. Having both in a single class meant there was multiple ways to be in an illegal state.

Instead, we now have a ShardCreator that should be used as a context manager, like so:

with ShardCreator("shard", object_count=len(objects)) as shard:
    for key, object in objects.items():
        shard.write(key, object)

The Shard class can now only be used to perform lookup(). The load() function was removed and inlined in initialization:

with Shard("shard") as shard:
    return shard.lookup(key)

Based on !14 (merged)

Edited by Jérémy Bobbio (Lunar)

Merge request reports