Skip to content


SequentialIDService (IDServiceInterface)

An ID service implementation that generates sequencial ids to aid debugging.

This ID service is intended to be used for debugging purposes only, since it relies on its internal state to generate ids.


Generate a unique ID.

This method guarantees that no two IDs it returns will be identical for the lifetime of the instantiated IDServiceInterface.


Type Description

The unique ID that was generated.

Source code in ofrak/service/
def generate_id(self) -> bytes:
    _id = self._ids[self._scope]
    self._ids[self._scope] += 1
    return struct.pack(">I", _id)

generate_id_from_base(base_id, key) staticmethod

Generate an ID based on a base ID and key.

This method returns the same ID each time it is called with the exact same parameters. It should therefore be used with caution: the callee needs to know that the parameters passed to this method are unique.


Name Type Description Default
base_id bytes

An ID used to derive the generated ID. This ID can be assumed to have been generated by the generate_id method.

key str

A key used to guarantee that the generated ID is unique. The callee is responsible for ensuring that this key is unique.



Type Description

The ID that was generated.

Source code in ofrak/service/
def generate_id_from_base(base_id: bytes, key: str) -> bytes:
    return b"-".join((base_id, bytes(key, "utf-8")))