Skip to content

Return a result from IO operations #3827

@d-v-b

Description

@d-v-b

As mentioned in #3748, our IO operations look like this:

def get(key) -> payload | None: ...
def set(key) -> None: ...

There's a similar story for the CodecPipeline class which has its own, slightly different IO API.

Practically this means we are throwing away a lot of useful information about each IO operation, such as how long these operations took, as well as store-specific metadata like http status codes.

Here is a proposed minimal API:

class GetResult(TypedDict):
  key: str
  duration: float
  status: Literal["success", "missing"]
  payload: NotRequired[bytes]

class SetResult(TypedDict):
  """TBD"""
   key: str
   duration: float

def get(key) -> GetResult: ...
def set(key) -> SetResult: ...

Our stores are all capable of giving us this information. We should probably use it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions