vaas

package
v0.11.36 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHook

func NewHook(cfg Config) (hook.Hook, error)

NewHook returns new instance of Hook.

Types

type Backend

type Backend struct {
	ID                 *int     `json:"id,omitempty"`
	Address            string   `json:"address,omitempty"`
	Director           string   `json:"director,omitempty"`
	DC                 DC       `json:"dc,omitempty"`
	Port               int      `json:"port,omitempty"`
	InheritTimeProfile bool     `json:"inherit_time_profile,omitempty"`
	Weight             *int     `json:"weight,omitempty"`
	Tags               []string `json:"tags,omitempty"`
	ResourceURI        string   `json:"resource_uri,omitempty"`
}

Backend represents JSON structure of backend in VaaS API.

type Client

type Client interface {
	FindDirectorID(string) (int, error)
	AddBackend(*Backend) (string, error)
	DeleteBackend(int) error
	GetDC(string) (*DC, error)
}

Client is an interface for VaaS API.

func NewClient

func NewClient(hostname string, username string, apiKey string) Client

NewClient creates new REST client for VaaS API.

type Config added in v0.9.0

type Config struct {
	// Enabled is a flag to control whether hook should be used
	Enabled bool `default:"true" envconfig:"vaas_hook_enabled"`
	// Varnish as a Service API url
	VaasAPIHost string `default:"" envconfig:"vaas_host"`
	// Varnish as a Service username
	VaasAPIUsername string `default:"" envconfig:"vaas_username"`
	// Varnish as a Service access token
	VaasAPIKey string `default:"" envconfig:"vaas_token"`
	// VaasAsyncTimeout is a timeout for async registration in VaaS
	VaasAsyncTimeout time.Duration `default:"90s" envconfig:"vaas_async_timeout"`
}

Config is Varnish configuration settable from environment

type DC

type DC struct {
	ID          int    `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	ResourceURI string `json:"resource_uri,omitempty"`
	Symbol      string `json:"symbol,omitempty"`
}

DC represents JSON structure of DC in VaaS API.

type DCList

type DCList struct {
	Meta    Meta `json:"meta,omitempty"`
	Objects []DC `json:"objects,omitempty"`
}

DCList represents JSON structure of DC list used in responses in VaaS API.

type Director

type Director struct {
	ID          int      `json:"id,omitempty"`
	Backends    []string `json:"backends,omitempty"`
	Name        string   `json:"name,omitempty"`
	ResourceURI string   `json:"resource_uri,omitempty"`
}

Director represents JSON structure of Director in VaaS API.

type DirectorList

type DirectorList struct {
	Meta    Meta       `json:"meta,omitempty"`
	Objects []Director `json:"objects,omitempty"`
}

DirectorList represents JSON structure of Director list used in responses in VaaS API.

type Hook

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

Hook manages lifecycle of Varnish backend related to executed service instance.

func (*Hook) DeregisterBackend

func (sh *Hook) DeregisterBackend(_ mesosutils.TaskInfo) error

DeregisterBackend deletes backend from VaaS.

func (*Hook) HandleEvent

func (sh *Hook) HandleEvent(event hook.Event) (hook.Env, error)

HandleEvent calls appropriate hook functions that correspond to supported event types. Unsupported events are ignored.

func (*Hook) RegisterBackend

func (sh *Hook) RegisterBackend(taskInfo mesosutils.TaskInfo) error

RegisterBackend adds new backend to VaaS if it does not exist.

type Meta

type Meta struct {
	Limit      int     `json:"limit,omitempty"`
	Next       *string `json:"next,omitempty"`
	Offset     int     `json:"offset,omitempty"`
	Previous   *string `json:"previous,omitempty"`
	TotalCount int     `json:"total_count,omitempty"`
}

Meta represents JSON structure of Meta in VaaS API.

type Task

type Task struct {
	Info        string `json:"info,omitempty"`
	ResourceURI string `json:"resource_uri,omitempty"`
}

Task represents JSON structure of a VaaS task in API.

Jump to

Keyboard shortcuts

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