sidecar

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 22 Imported by: 1

Documentation

Overview

Package sidecar implements the common engine of all Darvaza sidecars

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BindConfig

type BindConfig struct {
	Interfaces []string     `yaml:",omitempty" toml:",omitempty" json:",omitempty"`
	Addresses  []netip.Addr `yaml:",omitempty" toml:",omitempty" json:",omitempty"`

	KeepAlive time.Duration `yaml:"keep_alive,omitempty" toml:",omitempty" json:",omitempty" default:"10s"`
}

BindConfig refers to the IP addresses used by a GoShop Server

type Config

type Config struct {
	Logger  slog.Logger     `json:"-" yaml:"-" toml:"-"`
	Context context.Context `json:"-" yaml:"-" toml:"-"`
	Store   storage.Store   `json:"-" yaml:"-" toml:"-"`

	Name string `toml:"name" valid:"host,require"`

	Supervision SupervisionConfig
	Addresses   BindConfig `json:",omitempty" yaml:",omitempty" toml:",omitempty"`
	HTTP        HTTPConfig
	DNS         DNSConfig
}

Config represents the generic server configuration for Darvaza sidecars

func (*Config) New

func (cfg *Config) New() (*Server, error)

New creates a new Server from the Config

func (*Config) NewWithStore

func (cfg *Config) NewWithStore(s storage.Store) (*Server, error)

NewWithStore creates a new server using the given config and a prebuilt tls Store

func (*Config) SetDefaults

func (cfg *Config) SetDefaults() error

SetDefaults fills the gaps in the Config

func (*Config) Validate

func (cfg *Config) Validate() error

Validate tells if the configuration is worth a try

type DNSConfig added in v0.3.3

type DNSConfig struct {
	Enabled       bool          `yaml:"enabled"`
	Port          uint16        `yaml:"port"                default:"8053" valid:"port"`
	TLSPort       uint16        `yaml:"tls_port"            default:"8853" valid:"port"`
	MutualTLSOnly bool          `yaml:"mtls_only"`
	MaxTCPQueries int           `yaml:"max_tcp_queries"`
	ReadTimeout   time.Duration `yaml:"read_timeout"        default:"1s"`
	IdleTimeout   time.Duration `yaml:"idle_timeout"        default:"10s"`
}

DNSConfig contains information for setting up the DNS server

type HTTPConfig

type HTTPConfig struct {
	Port              uint16        `yaml:"port"                default:"8443" valid:"port"`
	PortInsecure      uint16        `yaml:"insecure_port"       default:"8080" valid:"port"`
	EnableInsecure    bool          `yaml:"enable_insecure"`
	MutualTLSOnly     bool          `yaml:"mtls_only"`
	ReadTimeout       time.Duration `yaml:"read_timeout"        default:"1s"`
	ReadHeaderTimeout time.Duration `yaml:"read_header_timeout" default:"2s"`
	WriteTimeout      time.Duration `yaml:"write_timeout"       default:"1s"`
	IdleTimeout       time.Duration `yaml:"idle_timeout"        default:"30s"`
}

HTTPConfig contains information for setting up the HTTP server

type Reloader

type Reloader interface {
	Reload() error
}

A Reloader is an application that can reload

type Server

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

Server is the HTTP Server of the sidecar

func New

func New(cfg *Config) (*Server, error)

New creates a new HTTP Server using the given Config

func (*Server) Cancel

func (srv *Server) Cancel()

Cancel initiates a shutdown of all workers

func (*Server) Err

func (srv *Server) Err() error

Err returns the reasons of the shutdown, if any

func (*Server) Fail

func (srv *Server) Fail(cause error)

Fail initiates a shutdown with a reason

func (*Server) Go

func (srv *Server) Go(run func(ctx context.Context) error)

Go runs a worker on the Server's Context

func (*Server) GoWithShutdown added in v0.3.3

func (srv *Server) GoWithShutdown(run func(context.Context) error, shutdown func() error)

GoWithShutdown runs a worker on the Server's Context, and a shutdown sentinel.

func (*Server) IsCancelled added in v0.3.3

func (srv *Server) IsCancelled() bool

IsCancelled tells if the server has been cancelled

func (*Server) Listen

func (srv *Server) Listen() error

Listen listens to all needed ports

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe(app http.Handler) error

ListenAndServe runs the Server

func (*Server) ListenWithListener

func (srv *Server) ListenWithListener(lc bind.TCPUDPListener) error

ListenWithListener listens to all needed ports using a net.ListenerConfig context

func (*Server) ListenWithUpgrader

func (srv *Server) ListenWithUpgrader(upg bind.Upgrader) error

ListenWithUpgrader listens to all needed ports using a ListenUpgrader like tableflip

func (*Server) Shutdown

func (srv *Server) Shutdown(timeout time.Duration) error

Shutdown initiates a shutdown of all workers with optional fatal timeout while waiting for the workers to finish.

func (*Server) Spawn

func (srv *Server) Spawn(h http.Handler, healthy time.Duration) error

Spawn starts the initial workers

func (*Server) Wait

func (srv *Server) Wait() error

Wait blocks until all workers have exited

type SupervisionConfig

type SupervisionConfig struct {
	PIDFile         string        `yaml:"pid_file"         default:"/tmp/tableflip.pid"`
	GracefulTimeout time.Duration `yaml:"graceful_timeout" default:"5s"`
	HealthWait      time.Duration `yaml:"health_wait"      default:"1s"`
}

SupervisionConfig represents how graceful upgrades will operate

Directories

Path Synopsis
Package dnsserver implements a DNS server for sidecars
Package dnsserver implements a DNS server for sidecars
Package horizon implements entrypoints based on the network they belong to
Package horizon implements entrypoints based on the network they belong to
Package httpserver implements a HTTP/HTTPS/HTTP3 server for darvaza sidecars.
Package httpserver implements a HTTP/HTTPS/HTTP3 server for darvaza sidecars.
Package store provides a TLS certificate manager for sidecars
Package store provides a TLS certificate manager for sidecars

Jump to

Keyboard shortcuts

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