dream_http_client/recorder

Recorder process and state management

Manages HTTP request/response recordings using a process to store state. Supports recording, playback, and passthrough modes.

Types

Recorder mode

pub type Mode {
  Record(directory: String)
  Playback(directory: String)
  Passthrough
}

Constructors

  • Record(directory: String)
  • Playback(directory: String)
  • Passthrough

Opaque recorder handle - contains subject for state management

pub opaque type Recorder

Values

pub fn add_recording(
  recorder: Recorder,
  rec: recording.Recording,
) -> Nil

Add a recording to the recorder

Only works in Record mode. In other modes, this is a no-op.

pub fn find_recording(
  recorder: Recorder,
  request: recording.RecordedRequest,
) -> option.Option(recording.Recording)

Find a matching recording for a request

Returns the matching recording if found, or None if not found. Only works in Playback mode. In other modes, returns None.

pub fn get_recordings(
  recorder: Recorder,
) -> List(recording.Recording)

Get all recordings from the recorder

Returns all recordings currently stored in the recorder.

pub fn is_record_mode(recorder: Recorder) -> Bool

Check if recorder is in Record mode

Returns true if the recorder is in Record mode, false otherwise.

pub fn start(
  mode: Mode,
  matching_config: matching.MatchingConfig,
) -> Result(Recorder, String)

Start a new recorder in the specified mode

Creates a process to manage recorder state internally. Multiple requests can share the same recorder by passing the same handle.

pub fn stop(recorder: Recorder) -> Result(Nil, String)

Stop the recorder and save recordings

In Record mode, saves all recordings to disk before stopping. In other modes, just stops the process. Returns an error if saving fails.

Search Document