client

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EnvClientTimeout = os.Getenv("CLIENT_TIMEOUT")
)
View Source
var (
	RetryDelay = 3 * time.Second
)

Functions

func HandleError

func HandleError(httpStatus int, msg string, okStatusCodes ...int) error

func NewHttpClientOrDie

func NewHttpClientOrDie(opts ...Option) client.HttpRequestDoer

Types

type CertRefresher

type CertRefresher struct {
	Pool *x509.CertPool
	// contains filtered or unexported fields
}

CertRefresher is a utility to refresh the CA certificates from a file periodically. It is useful for applications that need to maintain a valid certificate pool

func NewCertRefresher

func NewCertRefresher(filepath string) *CertRefresher

func (*CertRefresher) Start

func (c *CertRefresher) Start(ctx context.Context) (err error)

func (*CertRefresher) Watch

func (c *CertRefresher) Watch(ctx context.Context)

type HttpError

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

HttpError implement the common/pkg/errors/ctrlerrors.Error interface However, we do not want to introduce a dependency from common-server/pkg/client to common/pkg/errors

func BlockedErrorf

func BlockedErrorf(format string, a ...any) *HttpError

func RetryableErrorf

func RetryableErrorf(format string, a ...any) *HttpError

func RetryableWithDelayErrorf

func RetryableWithDelayErrorf(delay time.Duration, format string, a ...any) *HttpError

func (*HttpError) Error

func (e *HttpError) Error() string

func (*HttpError) IsBlocked

func (e *HttpError) IsBlocked() bool

func (*HttpError) IsRetryable

func (e *HttpError) IsRetryable() bool

func (*HttpError) RetryDelay

func (e *HttpError) RetryDelay() time.Duration

func (*HttpError) StatusCode

func (e *HttpError) StatusCode() int

func (*HttpError) WithStatusCode

func (e *HttpError) WithStatusCode(code int) *HttpError

type Option

type Option func(*Options)

func WithCaFilepath

func WithCaFilepath(caFilepath string) Option

func WithClientName

func WithClientName(name string) Option

func WithClientTimeout

func WithClientTimeout(timeout time.Duration) Option

func WithReplacePattern

func WithReplacePattern(pattern string) Option

func WithSkipTlsVerify

func WithSkipTlsVerify(skip bool) Option

type Options

type Options struct {
	// ClientName is used for metrics.
	ClientName string
	// ReplacePattern is used to obfuscate parts of the URL-path
	// used in metrics collections.
	ReplacePattern string
	// SkipTlsVerify skips TLS verification.
	SkipTlsVerify bool
	// CaFilepath is the path to the CA certificate file.
	// If empty, the system's default CA certificates are used.
	// If SkipTlsVerify is true, this option is ignored.
	CaFilepath string
	// ClientTimeout is the timeout for HTTP requests.
	ClientTimeout time.Duration
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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