ExUtcp.Transports.Grpc.Connection (ex_utcp v0.3.2)

Copy Markdown View Source

Manages gRPC connections with pooling and lifecycle management.

Summary

Functions

Returns a specification to start this module under a supervisor.

Closes the gRPC connection.

Gets the manual (available tools) from the gRPC service.

Checks if the connection is healthy.

Starts a new gRPC connection process.

Types

t()

@type t() :: %ExUtcp.Transports.Grpc.Connection{
  channel: GRPC.Channel.t(),
  connection_state: :connecting | :connected | :disconnected | :error,
  last_used: DateTime.t(),
  max_retries: non_neg_integer(),
  provider: map(),
  retry_count: non_neg_integer(),
  stub: module()
}

Functions

call_tool(pid, tool_name, args, timeout \\ 30000)

@spec call_tool(pid(), String.t(), map(), timeout()) ::
  {:ok, map()} | {:error, term()}

Calls a tool via gRPC.

call_tool_stream(pid, tool_name, args, timeout \\ 30000)

@spec call_tool_stream(pid(), String.t(), map(), timeout()) ::
  {:ok, [map()]} | {:error, term()}

Calls a tool stream via gRPC.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(pid)

@spec close(pid()) :: :ok

Closes the gRPC connection.

get_manual(pid, timeout \\ 30000)

@spec get_manual(pid(), timeout()) :: {:ok, [map()]} | {:error, term()}

Gets the manual (available tools) from the gRPC service.

healthy?(pid)

@spec healthy?(pid()) :: boolean()

Checks if the connection is healthy.

start_link(provider, opts \\ [])

@spec start_link(
  map(),
  keyword()
) :: {:ok, pid()} | {:error, term()}

Starts a new gRPC connection process.