adk_mcp_sse_stream (erlang_adk v0.10.0)

View Source

Incremental, credit-driven SSE decoder for MCP Streamable HTTP.

feed/3 never delivers more complete events than the owner has granted. Complete-but-undelivered input remains bounded inside the worker and the producer receives paused, making backpressure explicit. The worker is not linked to the owner, but monitors it and terminates immediately when the owner dies. decode/2 exposes the same parser as a pure helper for a transport process that already owns its receive loop.

Summary

Functions

cancel(Stream)

-spec cancel(pid()) -> ok.

code_change(OldVersion, State, Extra)

credit(Stream, Amount)

-spec credit(pid(), pos_integer()) -> ok | {error, term()}.

decode(State0, Chunk0, Fin)

-spec decode(map(), binary(), boolean()) ->
                {ok, [map()], map(), ready | paused | done} | {error, term()}.

feed(Stream, Chunk, Fin)

-spec feed(pid(), binary(), boolean()) ->
              {ok, non_neg_integer(), ready | paused | done} | {error, term()}.

finish(State)

-spec finish(map()) -> {ok, [map()], map(), done | paused} | {error, term()}.

format_status(Status)

grant(State, Amount)

-spec grant(map(), pos_integer()) -> {ok, map()} | {error, term()}.

handle_call(Request, From, State)

handle_cast(Message, State)

handle_info(Message, State)

init(_)

new(Options)

-spec new(map()) -> {ok, map()} | {error, term()}.

start(Owner, Options)

-spec start(pid(), map()) -> gen_server:start_ret().

start_link(Owner, Options)

-spec start_link(pid(), map()) -> gen_server:start_ret().

terminate(Reason, State)