Documentation
¶
Overview ¶
Package client implements the Unified Ferret API over gRPC. New creates and owns a channel with TLS by default; From borrows a caller-configured connection. Both return api.Runtime; plans, sessions, output, semantic options, and debugger values use github.com/MontFerret/api and its canonical subpackages.
The construction context bounds the handshake, while the returned runtime owns the logical connection lifetime. Runtime.Run invokes the hosted runtime directly. Plans create durable sessions whose runs are sequential. Callers close resources explicitly. Close gates new root calls while admitted work and retained descendants keep their lifetimes. Final logical release uses bounded detached cleanup, then closes a New-owned channel. From never closes transport. Failed startup returns a nil runtime; rollback can outlast startup cancellation.
Wire resource IDs, RPC clients, and watch streams remain private. Immediate remote failures expose Error, terminal failures use pkg/failure.Failure, and ErrClosed and ErrExecutionCancelled distinguish local closure and remote cancellation from the caller's context errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrClosed reports an operation attempted through a closed runtime or resource // handle. Closing begins when the first Close call commits teardown. ErrClosed = errors.New("Wire client or resource is closed") // ErrExecutionCancelled reports that a remote execution reached its cancelled // terminal state. It is distinct from cancellation of the caller's context. ErrExecutionCancelled = errors.New("remote execution was cancelled") )
Functions ¶
func From ¶
From completes the Wire handshake over a caller-owned gRPC connection. It accepts any non-nil ClientConnInterface and never closes the supplied transport, including on startup failure or logical-resource recovery. The context controls startup, not the returned runtime's lifetime. Failure returns a nil interface; bounded detached rollback may outlast cancellation.
func New ¶
New creates and owns a gRPC channel and completes the Wire handshake before returning a remote runtime. Transport defaults to TLS with system trust and server identity verification; plaintext requires WithInsecure. The context controls startup only. Cancellation after publication leaves the runtime usable. Failed startup returns a nil interface and performs bounded, detached rollback, which may take additional time after cancellation. Close gates new root calls; the channel closes after final logical release, including release deferred to admitted work or caller-owned descendants.
Types ¶
type ConnectionLifetime ¶
type ConnectionLifetime interface {
// ConnectionDone closes when the Connect reader ends, before final cleanup.
ConnectionDone() <-chan struct{}
// ConnectionError returns the retained cause of unexpected connection loss.
// An unexpected EOF yields ErrClosed. Before loss and for locally initiated
// teardown it returns nil. Read it after ConnectionDone for the final cause.
ConnectionError() error
}
ConnectionLifetime observes the logical Wire connection of a runtime returned by New or From. Runtime.Close can leave this connection alive for retained plans.
type Error ¶
type Error struct {
Category failure.Category
Message string
Diagnostics diagnostics.Diagnostics
// contains filtered or unexported fields
}
Error is a decoded Wire RPC failure. Category is set only when the server transmitted an ErrorDetail; transport-native statuses leave it zero. Internal transport causes remain available through Unwrap without exposing protocol resource identifiers.
type Option ¶
type Option func(*config) error
Option configures New's transport without acquiring ownership of credential providers. New applies non-nil options once in order and joins failures. Invalid options prevent channel creation, even when followed by an override.
func WithInsecure ¶
func WithInsecure() Option
WithInsecure selects plaintext, disabling transport encryption and peer authentication. It does not select TLS without certificate verification. Repetition is idempotent; explicit transport credentials conflict with it.
func WithPerRPCCredentials ¶
func WithPerRPCCredentials(creds credentials.PerRPCCredentials) Option
WithPerRPCCredentials appends a provider in registration order for every RPC, including Connect, subsequent unary and streaming calls, and detached cleanup. Providers may refresh credentials; gRPC enforces RequireTransportSecurity. Nil providers fail construction. Providers must support concurrent RPCs.
func WithTransportCredentials ¶
func WithTransportCredentials(creds credentials.TransportCredentials) Option
WithTransportCredentials replaces New's default TLS credentials. The last valid value wins. Nil credentials fail construction, and combining this option with WithInsecure fails in either order. The provider retains its own policy and external resources; Wire neither mutates nor closes it.
Source Files
¶
- allocation_context.go
- allocation_error.go
- client.go
- compile.go
- compile_options.go
- connection_lifetime.go
- constructor.go
- debug.go
- debug_command_result.go
- debug_conversion.go
- debug_events.go
- debug_inspection.go
- debug_output.go
- diagnostics.go
- doc.go
- errors.go
- execution.go
- execution_conversion.go
- execution_events.go
- lifecycle.go
- options.go
- params.go
- plan.go
- remote_debug_session.go
- remote_output.go
- remote_plan.go
- remote_session.go
- runtime.go
- runtime_allocation.go
- runtime_plan_options.go
- runtime_session_options.go
- runtime_transport.go
- session_handle.go