gonk.impl.fs
- class gonk.impl.fs.RecordKeeper(parent_directory: Path)
File system backed RecordKeeper.
Treats the event log as a linked list. Utilizes
headandtailfiles. Events are stored in depth=3 prefix-tree folder structure. For example, UUID96f76903-7b92-44d1-8e53-fc47a520684cwould be stored inrk/events/9/6/f/.- add(event: EventT)
Add a
gonk.core.events.Eventto storage.
- read(uuid_: UUID) Event
Read a
gonk.core.events.Eventfrom storage.- Raises:
ValueError – Event does not exist.
- exists(uuid_: UUID) bool
Check
gonk.core.events.Eventexistence.
- next(uuid_: UUID | None = None) UUID | None
- Get the next
gonk.core.events.Event’s UUID in the event history.
- Returns:
- The next event UUID in the event history
or None if the provided UUID is the tail.
- Raises:
ValueError – Event does not exist.
- Get the next
- tail() UUID | None
- Get the last
gonk.core.events.Event’s UUID in the event history.
- Returns:
- The last event UUID in the event history
or None when there are no events.
- Get the last
- class gonk.impl.fs.ObjectStateT(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Enum for Depot objects.
- NONEXISTENT = 1
Object does not exist.
- READABLE = 2
Object is readable.
- WRITABLE = 4
Object is writable.
- class gonk.impl.fs.Depot(parent_directory: Path)
File system backed Depot.
Objects are stored in depth=3 prefix-tree folder structure. For example, UUID
62af3937-4c5b-405b-a170-6ef12a5e246awould be stored indepot/6/2/a/. When an object is still writable it will have the.wrextension. Upon finalization this extension is removed.- exists(identifier: Identifier)
Check whether an object exists.
- reserve(identifier: Identifier, size: int)
Reserve an object identifier for writing.
- Raises:
StorageError – Identifier already exists.
- write(identifier: Identifier, offset: int, buf: bytes)
Write bytes to an object at an offset.
- Raises:
StorageError – Identifier not found.
StorageError – Object finalized.
- finalize(identifier: Identifier)
Finalize an object and make it readable.
- Raises:
StorageError – Identifier not found.
StorageError – Object already finalized.
- read(identifier: Identifier, offset: int, size: int)
Read size bytes of an object from offset.
- Raises:
StorageError – Identifier not found.
StorageError – Object not yet finalized.
- purge(identifier: Identifier)
Delete the object.
- Raises:
StorageError – Identifier not found.