lib

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRedisConn

func NewRedisConn(options Options) (redis.Conn, error)

NewRedisConn creates new redis connection

Types

type Client

type Client struct {
	Options Options
}

Client is the client used to connect to redis and send pubsub messages

func NewClient

func NewClient(options Options) *Client

NewClient creates a new instance of Client

func (*Client) Ban

func (c *Client) Ban(channels []string, host string, value []string) error

Ban issues a ban request, expression being a complete VCL ban expression

func (*Client) BanURL

func (c *Client) BanURL(channels []string, host string, value []string) error

BanURL issues a ban request with pattern matching the URL

func (*Client) Do

func (c *Client) Do(channels []string, req Request) error

Do sends a request to supplied pubsub channels

func (*Client) Purge

func (c *Client) Purge(channels []string, host string, value []string) error

Purge issues a purge request for the supplied path

func (*Client) Xkey

func (c *Client) Xkey(channels []string, host string, value []string) error

Xkey issues a purge request for supplied surrogate keys

func (*Client) XkeySoft

func (c *Client) XkeySoft(channels []string, host string, value []string) error

XkeySoft issues a soft-purge request for supplied surrogate keys

type Listener

type Listener struct {
	Options Options
}

Listener is used to connect to redis pubsub and listen for incoming requests

func NewListener

func NewListener(options Options) *Listener

NewListener creates a new Listener instance

func (*Listener) Listen

func (l *Listener) Listen() error

Listen starts listening for incoming requests

type Options

type Options struct {
	Redis struct {
		URI       string
		Password  string
		Subscribe []string
	}
	Endpoint struct {
		URI            string
		XkeyHeader     string
		SoftXkeyHeader string
		BanHeader      string
		BanURLHeader   string
	}
}

Options contains all settings read from the configuration file

type Request

type Request struct {
	Host    string   `json:"host,omitempty"`
	Command string   `json:"command"`
	Value   []string `json:"value"`
}

Request contains the purge message received from or sent to redis

func NewRequest

func NewRequest(jsonInput string) (*Request, error)

NewRequest create a new Request instance

func (*Request) Validate

func (r *Request) Validate() (bool, error)

Validate validates the request

type RequestProcessor

type RequestProcessor struct {
	Config Options
}

RequestProcessor converts an incoming pubsub message on redis to a purge request to be sent to varnish

func NewRequestProcessor

func NewRequestProcessor(options Options) *RequestProcessor

NewRequestProcessor creates a new RequestProcessor

func (*RequestProcessor) Process

func (rp *RequestProcessor) Process(jsonInput string) error

Process parses the request and sends it to varnish

func (*RequestProcessor) Send

func (rp *RequestProcessor) Send(req *Request) error

Send sends a purge request to varnish

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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