kurrentdb/operation/get_stream_metadata

Build and decode get-stream-metadata operations.

Stream metadata is stored as events in the stream named $$<stream>. This module reuses the read-stream operation to build the request and then decodes the first metadata event into stream_metadata.StreamMetadata.

Types

Errors that can occur while decoding stream metadata from read messages.

pub type ResponseError {
  EmptyResponse
  MetadataDecodeError(json.DecodeError)
  ReadStreamError(read_stream.ResponseError)
}

Constructors

  • EmptyResponse

    No metadata event was present in the supplied messages.

  • MetadataDecodeError(json.DecodeError)

    The metadata event body was not valid stream metadata JSON.

  • ReadStreamError(read_stream.ResponseError)

    Reading the metadata stream failed.

Values

pub fn decode_messages(
  messages: List(read_stream.ReadMessage),
) -> Result(stream_metadata.StreamMetadata, ResponseError)

Decode stream metadata from read messages.

Non-event read messages are ignored. The first recorded or resolved event is decoded as the metadata JSON document.

pub fn filter_events(
  messages: List(read_stream.ReadMessage),
) -> List(read_stream.ReadEvent)

Keep only read-event messages from a read response.

This is useful when handling raw read stream output before decoding stream metadata.

pub fn request(
  client: kurrentdb.Client,
  stream stream_name: String,
  config config: read_stream.Configuration,
) -> request.Request(BitArray)

Build a request to read metadata for a stream.

The request targets the metadata stream ($$<stream>) and uses the supplied read-stream configuration. Use a configuration that reads the latest metadata event if you only need the current metadata document.

Search Document