pluginsocket

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package pluginsocket connects a server to its plugin sidecar over a Unix socket. It depends on no plugin implementation, so a server that only calls a plugin does not link the plugin's storage SDKs.

Index

Constants

View Source
const ReadyWait = 30 * time.Second

ReadyWait is the ready wait servers pass to Dial. It rides through a sidecar restart, including the first 10s step of kubelet's crash-loop back-off, and fails a plugin that stays down well before a caller's deadline would.

Variables

This section is empty.

Functions

func CallError

func CallError(err error) error

CallError returns the error a server reports to its own caller for a failed plugin call. codes.Unavailable, which a call reports when the plugin cannot be reached, becomes an apierror.Unavailable so the server's caller retries rather than treating it as Internal. Any other error is returned unchanged.

func Dial

func Dial(path string, readyWait time.Duration) (*grpc.ClientConn, error)

Dial returns a long-lived client connection to a plugin socket. A unary call waits up to readyWait for the connection to become ready, then fails with codes.Unavailable, so a plugin that is lost after startup fails calls promptly while a brief restart does not. A call that starts on a ready connection is not bounded by readyWait, and one in flight when the plugin goes fails with codes.Unavailable at once. A caller that passes grpc.WaitForReady itself opts out of the bound and waits as long as its context allows; WaitReady does so at startup.

The bound covers unary calls only. A streaming call gets gRPC's plain fail-fast and fails at once while the plugin restarts, so the first streaming RPC on this connection needs a grpc.WithStreamInterceptor that applies the same wait.

The connection is unauthenticated: the socket is reachable only from inside the pod, and only by its owner.

func Listen

func Listen(path string) (net.Listener, error)

Listen removes any stale socket at path and listens on a fresh one that only the socket's owner can connect to.

func WaitReady

func WaitReady(ctx context.Context, conn *grpc.ClientConn) error

WaitReady blocks until the plugin behind conn reports that it is serving, or ctx ends, however long the plugin takes to come up. Bounding ctx is what turns a plugin that never comes up (a wrong socket path, a crash loop) into an error at startup.

Types

This section is empty.

Jump to

Keyboard shortcuts

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