Object.StreamProcessor (object v0.1.2)

Stream processor with backpressure control for ideation and data flow.

This module implements the concepts formally verified in our LEAN4 proofs, providing a concrete implementation of stream processing with backpressure that prevents buffer overflow and maintains quality of service.

Summary

Functions

Get current backpressure level (0.0 to 1.0).

Returns a specification to start this module under a supervisor.

Try to emit an element to the processor. Returns {:ok, :accepted} or {:error, :backpressure}.

Get current processor state and statistics.

Process one element from the buffer. Returns {:ok, element} or {:error, :empty}.

Starts a stream processor with given capacity.

Types

element()

@type element() :: {:idea, String.t(), float()} | {:data, any()} | :eof

t()

@type t() :: %Object.StreamProcessor{
  buffer: [element()],
  capacity: pos_integer(),
  pressure: float(),
  processed: non_neg_integer(),
  stats: map()
}

Functions

backpressure(processor)

Get current backpressure level (0.0 to 1.0).

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

emit(processor, element)

Try to emit an element to the processor. Returns {:ok, :accepted} or {:error, :backpressure}.

get_state(processor)

Get current processor state and statistics.

process_one(processor)

Process one element from the buffer. Returns {:ok, element} or {:error, :empty}.

start_link(opts \\ [])

Starts a stream processor with given capacity.