config

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Listeners []ListenerConfig `json:"listeners" yaml:"listeners"`

	Connect ConnectConfig `json:"connect" yaml:"connect"`

	Server ServerConfig `json:"server" yaml:"server"`

	Log log.Config `json:"log" yaml:"log"`

	// GracePeriod is the duration to gracefully shutdown the agent. During
	// the grace period, listeners and idle connections are closed, then waits
	// for active requests to complete and closes their connections.
	GracePeriod time.Duration `json:"grace_period" yaml:"grace_period"`
}

func Default added in v0.6.0

func Default() *Config

func (*Config) RegisterFlags

func (c *Config) RegisterFlags(fs *pflag.FlagSet)

func (*Config) Validate

func (c *Config) Validate() error

type ConnectConfig added in v0.3.0

type ConnectConfig struct {
	// URL is the Piko server URL to connect to.
	URL string

	// Token is a token to authenticate with the Piko server.
	Token string

	// Timeout is the timeout attempting to connect to the Piko server on
	// boot.
	Timeout time.Duration `json:"timeout" yaml:"timeout"`

	TLS TLSConfig `json:"tls" yaml:"tls"`
}

func (*ConnectConfig) RegisterFlags added in v0.3.0

func (c *ConnectConfig) RegisterFlags(fs *pflag.FlagSet)

func (*ConnectConfig) Validate added in v0.3.0

func (c *ConnectConfig) Validate() error

type ListenerConfig added in v0.3.0

type ListenerConfig struct {
	// EndpointID is the endpoint ID to register.
	EndpointID string `json:"endpoint_id" yaml:"endpoint_id"`

	// Addr is the address of the upstream service to forward to.
	Addr string `json:"addr" yaml:"addr"`

	// Protocol is the protocol to listen on. Supports "http" and "tcp".
	// Defaults to "http".
	Protocol ListenerProtocol `json:"protocol" yaml:"protocol"`

	// AccessLog indicates whether to log all incoming connections and requests
	// for the endpoint.
	AccessLog bool `json:"access_log" yaml:"access_log"`

	// Timeout is the timeout to forward incoming requests to the upstream.
	Timeout time.Duration `json:"timeout" yaml:"timeout"`
}

func (*ListenerConfig) Host added in v0.5.0

func (c *ListenerConfig) Host() (string, bool)

Host parses the given upstream address into a host and port. Return false if the address is invalid.

The addr may be either a a host and port or just a port.

func (*ListenerConfig) URL added in v0.3.0

func (c *ListenerConfig) URL() (*url.URL, bool)

URL parses the given upstream address into a URL. Return false if the address is invalid.

The addr may be either a full URL, a host and port or just a port.

func (*ListenerConfig) Validate added in v0.3.0

func (c *ListenerConfig) Validate() error

type ListenerProtocol added in v0.5.0

type ListenerProtocol string
const (
	ListenerProtocolHTTP ListenerProtocol = "http"
	ListenerProtocolTCP  ListenerProtocol = "tcp"
)

type ServerConfig

type ServerConfig struct {
	// BindAddr is the address to bind to listen for incoming HTTP connections.
	BindAddr string `json:"bind_addr" yaml:"bind_addr"`
}

func (*ServerConfig) RegisterFlags added in v0.2.0

func (c *ServerConfig) RegisterFlags(fs *pflag.FlagSet)

func (*ServerConfig) Validate

func (c *ServerConfig) Validate() error

type TLSConfig added in v0.3.0

type TLSConfig struct {
	// RootCAs contains a path to root certificate authorities to validate
	// the TLS connection to the Piko server.
	//
	// Defaults to using the host root CAs.
	RootCAs string `json:"root_cas" yaml:"root_cas"`
}

func (*TLSConfig) Load added in v0.3.0

func (c *TLSConfig) Load() (*tls.Config, error)

func (*TLSConfig) RegisterFlags added in v0.3.0

func (c *TLSConfig) RegisterFlags(fs *pflag.FlagSet, prefix string)

Jump to

Keyboard shortcuts

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