client

package
v1.0.0-alpha.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 28 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func From(ctx context.Context, connection grpc.ClientConnInterface) (api.Runtime, error)

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

func New(ctx context.Context, target string, options ...Option) (api.Runtime, error)

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.

func (*Error) Error

func (e *Error) Error() string

Error returns the sanitized Wire error message.

func (*Error) Is

func (e *Error) Is(target error) bool

Is preserves portable inspection and context error identities without replacing the underlying gRPC status.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap returns the underlying transport error for errors.Is and errors.As.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL