net

package
v0.0.0-...-9571a26 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultIdleConnTimeout = 10 * time.Second
	DefaultBaseUrl         = "http://localhost:8088"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

The ksqlDB client

func NewHTTPClient

func NewHTTPClient(options Options, logger log.Logger) (Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Do

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

Do delegates the given http.Request to the underlying http.Client

func (*Client) Get

func (c *Client) Get(url string) (*http.Response, error)

func (*Client) GetUrl

func (c *Client) GetUrl(endpoint string) string

func (*Client) Post

func (c *Client) Post(url, contentType string, body io.Reader) (*http.Response, error)

type Credentials

type Credentials struct {
	Username string `json:"username" mapstructure:"username"`
	Password string `json:"password" mapstructure:"password"`
}

Credentials holds the username and password

type HTTPClient

type HTTPClient interface {
	GetUrl(endpoint string) string
	Do(*http.Request) (*http.Response, error)
	Get(url string) (*http.Response, error)
	Post(url, contentType string, body io.Reader) (*http.Response, error)
	Close()
}

type HTTPClientFactory

type HTTPClientFactory interface {
	NewHTTPClient(options Options, logger log.Logger) (*Client, error)
}

type Options

type Options struct {
	// BaseUrl is the URL to your ksqldb server
	BaseUrl string
	// Credentials for BaseAuth remote user
	Credentials Credentials
	// Credentials for BaseAuth remote user
	BasicAuthToken string
	// AllowHTTP
	AllowHTTP bool
	// DisableKeepAlives see https://golang.org/pkg/net/http/#Transport.DisableKeepAlives
	DisableKeepAlives bool
	// DisableCompression see https://golang.org/pkg/net/http/#Transport.DisableCompression
	DisableCompression bool
	// ForceAttemptHTTP2 see https://golang.org/pkg/net/http/#Transport.ForceAttemptHTTP2
	ForceAttemptHTTP2 bool
	// MaxIdleConns see https://golang.org/pkg/net/http/#Transport.MaxIdleConns
	MaxIdleConns int
	// MaxIdleConnsPerHost see https://golang.org/pkg/net/http/#Transport.MaxIdleConnsPerHost
	MaxIdleConnsPerHost int
	// MaxConnsPerHost see https://golang.org/pkg/net/http/#Transport.MaxConnsPerHost
	MaxConnsPerHost int
	// WriteBufferSize see https://golang.org/pkg/net/http/#Transport.WriteBufferSize
	WriteBufferSize int
	// ReadBufferSize see https://golang.org/pkg/net/http/#Transport.ReadBufferSize
	ReadBufferSize int
	// MaxResponseHeaderBytes see
	// https://golang.org/pkg/net/http/#Transport.MaxResponseHeaderBytes
	MaxResponseHeaderBytes int64
	// Timeout sets all Timeouts, that are set to 0 to the given
	// value. Basically it's the default timeout value.
	Timeout time.Duration
	// TLSHandshakeTimeout see
	// https://golang.org/pkg/net/http/#Transport.TLSHandshakeTimeout,
	// if not set or set to 0, its using Options.Timeout.
	TLSHandshakeTimeout time.Duration
	// IdleConnTimeout see
	// https://golang.org/pkg/net/http/#Transport.IdleConnTimeout,
	// if not set or set to 0, its using Options.Timeout.
	IdleConnTimeout time.Duration
	// ResponseHeaderTimeout see
	// https://golang.org/pkg/net/http/#Transport.ResponseHeaderTimeout,
	// if not set or set to 0, its using Options.Timeout.
	ResponseHeaderTimeout time.Duration
	// ExpectContinueTimeout see
	// https://golang.org/pkg/net/http/#Transport.ExpectContinueTimeout,
	// if not set or set to 0, its using Options.Timeout.
	ExpectContinueTimeout time.Duration
	// Tracer instance, can be nil to not enable tracing
	Tracer opentracing.Tracer
	// OpentracingComponentTag sets component tag for all requests
	OpentracingComponentTag string
	// OpentracingSpanName sets span name for all requests
	OpentracingSpanName string
}

Options configures the Client

type Transport

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

Transport wraps an http.Transport and adds support for tracing and http2.

func NewTransport

func NewTransport(options Options) *Transport

NewTransport creates a new Transport with Options

func WithComponentTag

func WithComponentTag(t *Transport, componentName string) *Transport

WithComponentTag sets the component name, if you have an enabled tracing Transport.

func WithSpanName

func WithSpanName(t *Transport, spanName string) *Transport

WithSpanName sets the name of the span, if you have an enabled tracing Transport.

func (*Transport) Close

func (t *Transport) Close()

Close the transport

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip the request with tracing and add client tracing: DNS, TCP/IP, TLS handshake, connection pool access. Client traces are added as logs into the created span.

type TransportFactory

type TransportFactory interface {
	NewTransport(options Options) *Transport
}

Jump to

Keyboard shortcuts

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