Skip to main content

Module batch

Module batch 

Source
Expand description

Axum extractor for batch operation streams.

BatchOperationStream reads a multipart request body one part at a time, detects the BatchFormat from the first part, and maps the parts onto a lazy stream of Operations.

All insert metadata uses the shared request timestamp, even for fields parsed later while streaming the body.

An invalid operation fails on its own, and reading continues with the next part. A broken multipart body, such as a truncated body or unparseable part headers, yields one error and ends the stream, because no further part can be found after it.

§JSON layout

Each operation is a descriptor part named by its index ("0", "1", …), whose body is a JSON object with kind, key (optional for inserts) and, for inserts, an optional WriteMetadata object. An insert is directly followed by its payload part "<i>.payload". The parser applies these rules:

  • A part whose name ends in .payload is a payload part. Every other part is a descriptor.
  • The index of an operation is the position of its descriptor among descriptor parts. A descriptor with another name, invalid JSON, or a missing required field fails with 400.
  • An insert without its payload part fails with 400, and the next part is read as the next descriptor. Any other payload part is skipped.
  • The stored content type is metadata.content_type. If that is absent and the payload is not encoded, it is the payload part’s Content-Type, and otherwise application/octet-stream.

Both layouts allow 1000 operations per request and 1 MiB per part. The JSON layout counts descriptor parts toward the operation limit and caps each descriptor at 64 KiB.

Structs§

BatchOperationStream
A lazily-parsed stream of batch operations extracted from a multipart request body.

Enums§

BatchError
Errors that can occur when processing or executing batch operations.
BatchFormat
The part layout of a batch request. The response uses the same layout.