client

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCapNotMatch = errors.New("capture not match")
View Source
var ErrCapResponse = errors.New("capture response error")

Functions

func AppendFile

func AppendFile(name string, data []byte, perm os.FileMode) error

func CaptureEqualRequestURL

func CaptureEqualRequestURL() mw_client_model.CaptureMatcher

func CaptureEqualRequestURLAndHeader

func CaptureEqualRequestURLAndHeader(header string) mw_client_model.CaptureMatcher

func CaptureReMatcherRequestURL

func CaptureReMatcherRequestURL() mw_client_model.CaptureMatcher

func DecorateHttpClient

func DecorateHttpClient(httpClient *http.Client,
	traceAttributes map[string]string,
	metricName string, metricDescription string, metricLabels map[string]string,
	buildinfo model.BuildInfo,
	log *slog.Logger, logReqLevel slog.Level, logRespLevel slog.Level,
	captureConfig srv_configs.CaptureConfiger,
) *http.Client

func IsNilish

func IsNilish(val any) bool

func NewHttpClient added in v0.0.4

func NewHttpClient(hostname string, serviceName string, targetServiceName string,
	buildInfo model.BuildInfo, captureConfig srv_configs.CaptureConfiger,
	log *slog.Logger, logReqLevel slog.Level, logRespLevel slog.Level,
) *http.Client

func TouchFile

func TouchFile(name string, perm os.FileMode) error

Types

type CaptureTransport

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

func NewCaptureTransport

func NewCaptureTransport(base http.RoundTripper, mode model.CaptureTransportMode, dirPath string, capMatchers []mw_client_model.CaptureMatcher) *CaptureTransport

func (*CaptureTransport) RoundTrip

func (t *CaptureTransport) RoundTrip(r *http.Request) (*http.Response, error)

type DelayedReaderPersister

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

func NewDelayedReaderPersister

func NewDelayedReaderPersister(body io.ReadCloser) *DelayedReaderPersister

func (*DelayedReaderPersister) Close

func (drp *DelayedReaderPersister) Close() error

func (*DelayedReaderPersister) Done

func (drp *DelayedReaderPersister) Done() <-chan struct{}

func (*DelayedReaderPersister) IsNil

func (drp *DelayedReaderPersister) IsNil() bool

func (*DelayedReaderPersister) Payload

func (drp *DelayedReaderPersister) Payload() []byte

func (*DelayedReaderPersister) Read

func (drp *DelayedReaderPersister) Read(p []byte) (n int, err error)

type LogTransport

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

LogTransport implements the http.RoundTripper interface and wraps outbound HTTP(S) requests with logs.

func NewLogTransport

func NewLogTransport(base http.RoundTripper, beginLevel slog.Level, endLevel slog.Level) *LogTransport

NewLogTransport wraps the provided http.RoundTripper with one that logs request and respnse.

If the provided http.RoundTripper is nil, http.DefaultTransport will be used as the base http.RoundTripper.

func (*LogTransport) RoundTrip

func (t *LogTransport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip logs outgoing request and response.

type MetricTransport

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

MetricTransport implements the http.RoundTripper interface and wraps outbound HTTP(S) requests with metrics.

func NewMetricTransport

func NewMetricTransport(base http.RoundTripper, meter metric_api.Meter, name string,
	description string, attributes map[string]string, errFormatter middleware.ErrFormatter,
) *MetricTransport

NewMetricTransport wraps the provided http.RoundTripper with one that meters metrics.

If the provided http.RoundTripper is nil, http.DefaultTransport will be used as the base http.RoundTripper.

func (*MetricTransport) RoundTrip

func (t *MetricTransport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip meters outgoing request-response pair.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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