transport

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package transport provides a flavor-agnostic HTTP layer: a thin client that applies request decorators (auth, user-agent) and retries transient failures.

This package backs the openobserve-cli command layer and is also importable as a library; see the repository README. The CLI relies on its retry, timeout and decorator behavior; change it additively and keep the defaults stable rather than tuning them for a single local call site.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a retrying HTTP client. It is flavor-agnostic: callers build fully formed *http.Request values and Client only adds decorators and retries.

func New

func New(opt Options) *Client

New builds a Client from Options, filling defaults.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request) (*http.Response, error)

Do sends req, applying decorators and retrying transient failures. The returned response (if any) has a readable, non-nil Body that the caller must close. The context bounds the whole retry sequence.

type Decorator

type Decorator func(*http.Request)

Decorator mutates an outgoing request before it is sent (e.g. adds headers).

type Doer

type Doer interface {
	Do(*http.Request) (*http.Response, error)
}

Doer executes an HTTP request. *http.Client satisfies it; tests inject fakes.

type Options

type Options struct {
	// Doer executes requests. Defaults to an *http.Client with Timeout.
	Doer Doer
	// Timeout is the per-request timeout when Doer is nil.
	Timeout time.Duration
	// MaxRetries is the number of additional attempts after the first failure.
	MaxRetries int
	// RetryBaseDelay is the base backoff delay; the Nth retry waits N*base.
	RetryBaseDelay time.Duration
	// Decorators are applied to every request in order.
	Decorators []Decorator
}

Options configures a Client.

Jump to

Keyboard shortcuts

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