gonk.impl.fs

class gonk.impl.fs.RecordKeeper(parent_directory: Path)

File system backed RecordKeeper.

Treats the event log as a linked list. Utilizes head and tail files. Events are stored in depth=3 prefix-tree folder structure. For example, UUID 96f76903-7b92-44d1-8e53-fc47a520684c would be stored in rk/events/9/6/f/.

add(event: EventT)

Add a gonk.core.events.Event to storage.

read(uuid_: UUID) Event

Read a gonk.core.events.Event from storage.

Raises:

ValueError – Event does not exist.

exists(uuid_: UUID) bool

Check gonk.core.events.Event existence.

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.

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.

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-6ef12a5e246a would be stored in depot/6/2/a/. When an object is still writable it will have the .wr extension. 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:
finalize(identifier: Identifier)

Finalize an object and make it readable.

Raises:
read(identifier: Identifier, offset: int, size: int)

Read size bytes of an object from offset.

Raises:
purge(identifier: Identifier)

Delete the object.

Raises:

StorageError – Identifier not found.