barrel_mcp_client_shell (barrel_mcp v3.0.0)

View Source

One supervisor per client, holding that client's restart budget so a client that cannot come back exhausts its own budget and nobody else's.

The client is a transient child: a crash restarts it under the same ServerId, a normal exit (the server closed the connection) does not, and since the client is the shell's only significant child the shell shuts itself down when that happens, which frees the id. A budget exhausted ends the shell the same way.

Summary

Functions

The client's pid, restarting while a failed restart is being retried, undefined when there is none.

Start the shell and, under it, the client for Spec. The spec's restart => #{intensity, period} is the client's own budget: at most intensity restarts in period seconds, 5 in 60 by default.

Functions

client(Shell)

-spec client(pid()) -> pid() | restarting | undefined.

The client's pid, restarting while a failed restart is being retried, undefined when there is none.

init(_)

start_link(ServerId, Spec)

-spec start_link(term(), barrel_mcp_client:connect_spec()) -> {ok, pid()} | {error, term()}.

Start the shell and, under it, the client for Spec. The spec's restart => #{intensity, period} is the client's own budget: at most intensity restarts in period seconds, 5 in 60 by default.