varnishadm

package
v0.0.0-...-54c5aff Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//VarninshAdmBinary binary to execute to control a varnish instance
	VarninshAdmBinary = "varnishadm"
	//VCLStatusAvailable - VCL configuration status
	VCLStatusAvailable = "available"
	//VCLStatusActive - VCL configuration is active now
	VCLStatusActive = "active"
	//VCLStatusDiscarded - VCL configuration is discarded but still in use by in-flight requests
	VCLStatusDiscarded = "discarded"
	//VCLTemperatureCold - vanish VCL "temperature"
	VCLTemperatureCold = "cold"
	//VCLTemperatureWarm for preloaded varnish's VCL
	VCLTemperatureWarm = "warm"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Commander

type Commander interface {
	Ping() error
	Reload(version, entry string) ([]byte, error)
	List() ([]VCLConfig, error)
	Discard(vclConfigName string) error
}

Commander defines the interface to use for call external utilities to manage varnish instance. - Ping() check if a varnish instace ready and reachable - Reload() try to load a new varnish VCL configuration - List() returns the VCL config currently used in varnish

type VCLConfig

type VCLConfig struct {
	Status        string
	Name          string
	State         string
	Busy          int
	Label         bool
	Temperature   string
	ReferencedVCL *string //nil if Label == false
}

VCLConfig represents varnish's config list

type VarnishAdm

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

VarnishAdm is a structure which implements Commander interface. it wraps call to external binaries to use varnish_adm binary from a varnish distribution to Commander interface specific methods

func NewVarnishAdministartor

func NewVarnishAdministartor(timeout, delay time.Duration, vclBase string, args []string) *VarnishAdm

NewVarnishAdministartor returns a wrapper over system command which allows ping, list and relod a varnishd it accepts following parameters: - timeout: an overall timeout to try to reach a varnish instance - delay: a delay between ping retry - vclBase: base directory for varnish's VCL files - args: varnisadm utility CLI parameters

func (*VarnishAdm) Discard

func (v *VarnishAdm) Discard(vclConfigName string) error

Discard deletes an existing VCL from the Varnish instance it is a wrapper over varnishadm vcl.discard command

func (*VarnishAdm) GetActiveConfigurationName

func (v *VarnishAdm) GetActiveConfigurationName() (string, error)

GetActiveConfigurationName parses varnishadm list output and compute a name of active configuration

func (*VarnishAdm) List

func (v *VarnishAdm) List() ([]VCLConfig, error)

List returns a list of VCL names which had been loaded into the varnish instance. it is a wrapper over varnishadm vcl.list command

func (*VarnishAdm) Ping

func (v *VarnishAdm) Ping() error

Ping try to reach varnish instance to ensure it is up and running. It applies pingDelay value as a maximum time to try to reach the varnish instance it is a wrapper over varnishadm ping command.

func (*VarnishAdm) Reload

func (v *VarnishAdm) Reload(version, entry string) ([]byte, error)

Reload loads new VCL configuration into the varnish instance. Accepts two string parameters - version string, a version which describes the configuration - entrypoint string, a start filename to use as a new VCL configuration it is a wrapper over varnishadm vcl.load and vcl.use commands combination

type VarnishAdministrator

type VarnishAdministrator interface {
	GetActiveConfigurationName() (name string, err error)
	Commander
}

VarnishAdministrator the Commander interface extension by the funtcion which returns active configuration name. - GetActiveConfigurationName() returns an active VCL configuration name or error

Jump to

Keyboard shortcuts

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