vaas

package
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2018 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// StatusPending Task state is unknown (assumed pending since you know the id).
	StatusPending = TaskStatus("PENDING")
	// StatusReceived Task was received by a worker (only used in events).
	StatusReceived = TaskStatus("RECEIVED")
	// StatusStarted Task was started by a worker (task_track_started).
	StatusStarted = TaskStatus("STARTED")
	// StatusSuccess Task succeeded
	StatusSuccess = TaskStatus("SUCCESS")
	// StatusFailure Task failed
	StatusFailure = TaskStatus("FAILURE")
	// StatusRevoked Task was revoked.
	StatusRevoked = TaskStatus("REVOKED")
	// StatusRetry Task is waiting for retry.
	StatusRetry = TaskStatus("RETRY")
)

Variables

This section is empty.

Functions

This section is empty.

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, bool) (string, error)
	DeleteBackend(int) error
	GetDC(string) (*DC, error)
	TaskStatus(*Task) 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 {
	// 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"`
	Cluster     []string `json:"cluster,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 NewHook

func NewHook(cfg Config) (*Hook, error)

NewHook returns new instance of Hook.

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"`
	Status      TaskStatus `json:"status,omitempty"`
}

Task represents JSON structure of a VaaS task in API.

type TaskStatus

type TaskStatus string

TaskStatus is a type representing task status from VaaS API responses.

Jump to

Keyboard shortcuts

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