plugin

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 8 Imported by: 0 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 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

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

func HTTPClientTransport(c *http.Client) *http.Transport

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

func NewHTTPClient(opts *Options) *http.Client

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

func HeaderOption(header http.Header) Option

HeaderOption sets custom HTTP headers sent with each request (HTTP transport only).

func TLSConfigOption

func TLSConfigOption(cfg *tls.Config) Option

TLSConfigOption sets the TLS configuration for transport security.

func TimeoutOption

func TimeoutOption(timeout time.Duration) Option

TimeoutOption sets the request timeout (HTTP transport only).

func TokenOption

func TokenOption(token string) Option

TokenOption sets the authentication token sent with each request.

type Options

type Options struct {
	Token     string
	TLSConfig *tls.Config
	Header    http.Header
	Timeout   time.Duration
}

Options holds the common configuration for gRPC and HTTP plugin clients.

Jump to

Keyboard shortcuts

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