# README
Go client for the Varnish administration port
This repository contains a client library that can be used to connect to the Varnish administration port (typically used by the varnishadm tool).
NOTE: Experimental. Use at own peril!
Installation
Install this library via go get
:
$ go get github.com/martin-helmich/go-varnish-client
Usage
Establish a connection
First, connect to the administration port using the varnishclient.DialTCP
method:
client, err := varnishclient.DialTCP(context.Background(), "127.0.0.1:6082")
if err != nil {
panic(err)
}
Authenticate
You can then use the client.AuthenticationRequired()
method to check if the Varnish server requires authentication.
Then, use the client.Authenticate()
method to perform the authentication:
secret, _ := ioutil.ReadFile("/etc/varnish/secret")
if client.AuthenticationRequired() {
err := client.Authenticate(context.Background(), secret)
if err != nil {
panic(err)
}
}
Define and update a new configuration
ctx := context.Background()
err := client.DefineInlineVCL(ctx, "my-new-config", vclCode, "warm")
if err != nil {
panic(err)
}
err = client.UseVCL(ctx, "my-new-config")
if err != nil {
panic(err)
}
Define timeouts/cancellations on operations
All operations accept a context.Context
parameter that can be used for timeouts and/or cancellations:
ctx, cancel := context.WithTimeout(context.Background(), 1 * time.Second)
defer cancel()
err := client.DefineInlineVCL(ctx, "my-new-config", vclCode, "warm")
if err != nil {
panic(err)
}
# Packages
No description provided by the author
# Functions
DialTCP connects to an existing Varnish administration port.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
These constants define the usual response codes returned by the Varnish admin server.
These constants define the usual response codes returned by the Varnish admin server.
These constants define the usual response codes returned by the Varnish admin server.
These constants define the usual response codes returned by the Varnish admin server.
These constants define the usual response codes returned by the Varnish admin server.
These constants define the usual response codes returned by the Varnish admin server.
These constants define the usual response codes returned by the Varnish admin server.
These constants define the usual response codes returned by the Varnish admin server.
These constants define the usual response codes returned by the Varnish admin server.
These constants define the usual response codes returned by the Varnish admin server.
These constants define the usual response codes returned by the Varnish admin server.
No description provided by the author
No description provided by the author
No description provided by the author
VCLStateAuto means that Varnish should automatically switch the VCL state from "warm" to "cold" and back.
VCLStateCold means that the VCL should always be "cold".
VCLStateWarm means that the VCL should always be "warm".
No description provided by the author
# Structs
Backend is a single item of the list returned by the `ListBackends` method.
Client contains the most common Varnish administration operations (and the necessary tools to build your own that are not yet implemented).
Parameter is a single item of the list returned by the `ListParameters` method.
Request contains the data sent to Varnish as a request.
Response contains the data that was received from Varnish in response to a request.
No description provided by the author
# Interfaces
ClientInterface describes the common methods offered by the Varnish client.
Roundtrip defines the interface for sending requests to Varnish and receiving responses.
# Type aliases
BackendsResponse is the respose type of the `ListBackends` method.
No description provided by the author
No description provided by the author
No description provided by the author
ParametersResponse is the response type of the `ListParameters` method.
No description provided by the author
No description provided by the author
VCLState describes one of the three possible VCL states See https://varnish-cache.org/docs/trunk/reference/varnish-cli.html#vcl-state-configname-auto-cold-warm.