gateway

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DISTRIBUTOR  = "distributor"
	FRONTEND     = "frontend"
	ALERTMANAGER = "alertmanager"
	RULER        = "ruler"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Authentication

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

func NewAuthentication

func NewAuthentication(config *Config) *Authentication

func (Authentication) Wrap

func (a Authentication) Wrap(next http.Handler) http.Handler

type Config

type Config struct {
	Server        ServerConfig `yaml:"server"`
	Admin         ServerConfig `yaml:"admin"`
	Tenants       []Tenant     `yaml:"tenants"`
	Distributor   Upstream     `yaml:"distributor"`
	QueryFrontend Upstream     `yaml:"frontend"`
	Alertmanager  Upstream     `yaml:"alertmanager"`
	Ruler         Upstream     `yaml:"ruler"`
}

func Init

func Init(filePath string) (Config, error)

type CustomTransport

type CustomTransport struct {
	http.Transport
	// contains filtered or unexported fields
}

CustomTransport wraps http.Transport and embeds the round-robin load balancer.

func (*CustomTransport) RoundTrip

func (ct *CustomTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip sends the HTTP request using round-robin load balancing.

type DNSResolver

type DNSResolver interface {
	LookupIP(string) ([]net.IP, error)
}

type DefaultDNSResolver

type DefaultDNSResolver struct{}

func (DefaultDNSResolver) LookupIP

func (d DefaultDNSResolver) LookupIP(hostname string) ([]net.IP, error)

type Gateway

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

func New

func New(config *Config, srv *server.Server) (*Gateway, error)

func (*Gateway) Start

func (g *Gateway) Start(config *Config)

type Proxy

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

func NewProxy

func NewProxy(targetURL string, upstream Upstream, component string) (*Proxy, error)

func (*Proxy) Handler

func (p *Proxy) Handler(w http.ResponseWriter, r *http.Request)

type ServerConfig

type ServerConfig struct {
	Address      string        `yaml:"address"`
	Port         int           `yaml:"port"`
	ReadTimeout  time.Duration `yaml:"http_server_read_timeout"`
	WriteTimeout time.Duration `yaml:"http_server_write_timeout"`
	IdleTimeout  time.Duration `yaml:"http_server_idle_timeout"`
}

type Tenant

type Tenant struct {
	Authentication string `yaml:"authentication"`
	Username       string `yaml:"username"`
	Password       string `yaml:"password"`
	ID             string `yaml:"id"`
}

type Upstream

type Upstream struct {
	URL                             string        `yaml:"url"`
	Paths                           []string      `yaml:"paths"`
	DNSRefreshInterval              time.Duration `yaml:"dns_refresh_interval"`
	HTTPClientTimeout               time.Duration `yaml:"http_client_timeout"`
	HTTPClientDialerTimeout         time.Duration `yaml:"http_client_dialer_timeout"`
	HTTPClientTLSHandshakeTimeout   time.Duration `yaml:"http_client_tls_handshake_timeout"`
	HTTPClientResponseHeaderTimeout time.Duration `yaml:"http_client_response_header_timeout"`
}

Jump to

Keyboard shortcuts

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