Documentation
¶
Overview ¶
Package plugin provides shared utilities for building gRPC and HTTP plugin clients. Both transport types support authentication tokens, TLS configuration, custom headers (HTTP), and connection timeouts.
Index ¶
Constants ¶
const ( // GRPC is the transport type identifier for gRPC-based plugins. GRPC string = "grpc" // HTTP is the transport type identifier for HTTP-based plugins. HTTP string = "http" )
Variables ¶
This section is empty.
Functions ¶
func HTTPClientTransport ¶ added in v0.28.1
HTTPClientTransport returns the *http.Transport underlying c, or nil if c's transport is not an *http.Transport. When the client was created with a non-empty Token, the *http.Transport is unwrapped from the tokenTransport wrapper. Callers that hold the client for a long time should call tr.CloseIdleConnections() when the client is no longer needed.
func NewGRPCConn ¶
func NewGRPCConn(addr string, opts *Options) (*grpc.ClientConn, error)
NewGRPCConn creates a gRPC client connection to addr. If opts is nil or opts.TLSConfig is nil, the connection uses insecure transport. When opts.Token is set, it is attached as per-RPC credentials.
func NewHTTPClient ¶
NewHTTPClient creates an http.Client from opts. If opts is nil, a default client with no timeout is returned. When opts.Token is set, the returned client's transport is wrapped so that each outgoing request carries an "Authorization: Bearer <token>" header (unless the caller has already set its own Authorization header). Use HTTPClientTransport to access the underlying *http.Transport and close idle connections when the client is no longer needed.
Types ¶
type Option ¶
type Option func(opts *Options)
Option configures Options.
func HeaderOption ¶
HeaderOption sets custom HTTP headers sent with each request (HTTP transport only).
func TLSConfigOption ¶
TLSConfigOption sets the TLS configuration for transport security.
func TimeoutOption ¶
TimeoutOption sets the request timeout (HTTP transport only).
func TokenOption ¶
TokenOption sets the authentication token sent with each request.