sidecar

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 20 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 `toml:"interfaces"`
	Addresses  []string `toml:"addresses" valid:"ip"`
}

BindConfig refers to the IP addresses used by a GoShop Server

type Config

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

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

	Supervision SupervisionConfig `toml:"run"`
	Addresses   BindConfig        `toml:",omitempty"`
	TLS         TLSConfig         `toml:"tls"`
	HTTP        HTTPConfig        `toml:"http"`
}

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 HTTPConfig

type HTTPConfig struct {
	Port              uint16        `toml:"port"                default:"8443" valid:"port"`
	PortInsecure      uint16        `toml:"insecure_port"       default:"8080" valid:"port"`
	EnableInsecure    bool          `toml:"enable_insecure"`
	MutualTLSOnly     bool          `toml:"mtls_only"`
	ReadTimeout       time.Duration `toml:"read_timeout"        default:"1s"`
	ReadHeaderTimeout time.Duration `toml:"read_header_timeout" default:"2s"`
	WriteTimeout      time.Duration `toml:"write_timeout"       default:"1s"`
	IdleTimeout       time.Duration `toml:"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) Cancelled

func (srv *Server) Cancelled() bool

Cancelled tells if the server has been cancelled

func (*Server) Err

func (srv *Server) Err() error

Err returns the reasons of the shutdown, if any

func (*Server) Fail

func (srv *Server) Fail(err error)

Fail initiates a shutdown with a reason

func (*Server) Go

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

Go runs a worker on the Server's Context

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        `toml:"pid_file"         default:"/tmp/tableflip.pid"`
	GracefulTimeout time.Duration `toml:"graceful_timeout" default:"5s"`
	HealthWait      time.Duration `toml:"health_wait"      default:"1s"`
}

SupervisionConfig represents how graceful upgrades will operate

type TLSConfig

type TLSConfig struct {
	Key   string `toml:"key"    default:"key.pem"`
	Cert  string `toml:"cert"   default:"cert.pem"`
	Roots string `toml:"caroot" default:"caroot.pem"`
}

TLSConfig contains information for setting up TLS clients and server

Jump to

Keyboard shortcuts

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