api

package
v0.0.0-...-93d971c Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2017 License: Apache-2.0, Apache-2.0 Imports: 4 Imported by: 0

README

robin-api

Contains the structure definitions used by Robin in its ETCD interface.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	IDNotFoundError  = restkit.NotFoundError("not found", 0)
	DuplicateIDError = restkit.BadRequestError("duplicate ID", codeDuplicateID)
	ValidationError  = restkit.BadRequestError("validation", codeValidation)
)

Functions

func IsDuplicateID

func IsDuplicateID(err error) bool

IsDuplicateID returns true if the cause of the given error is DuplicateIDError.

func IsIDNotFound

func IsIDNotFound(err error) bool

IsIDNotFound returns true if the cause of the given error is IDNotFoundError.

func IsValidation

func IsValidation(err error) bool

IsValidation returns true if the cause of the given error is ValidationError.

Types

type API

type API interface {
	// Add adds a given frontend record with given ID to the list of frontends.
	// If the given ID already exists, a DuplicateIDError is returned.
	Add(id string, record FrontendRecord) error

	// Remove a frontend with given ID.
	// If the ID is not found, an IDNotFoundError is returned.
	Remove(id string) error

	// All returns a map of all known frontend records mapped by their ID.
	All() (map[string]FrontendRecord, error)

	// Get returns the frontend record for the given id.
	// If the ID is not found, an IDNotFoundError is returned.
	Get(id string) (FrontendRecord, error)
}

API is the client interface for controlling the frontends of the Robin loadbalancer.

func NewClient

func NewClient(baseURL *url.URL) (API, error)

NewClient creates a new API implementation for the given base URL.

type FrontendRecord

type FrontendRecord struct {
	Selectors       []FrontendSelectorRecord `json:"selectors"`
	Service         string                   `json:"service,omitempty"`
	Mode            string                   `json:"mode,omitempty"` // http|tcp
	HttpCheckPath   string                   `json:"http-check-path,omitempty"`
	HttpCheckMethod string                   `json:"http-check-method,omitempty"`
	Sticky          bool                     `json:"sticky,omitempty"`
	Backup          bool                     `json:"backup,omitempty"`
}

func (FrontendRecord) Validate

func (r FrontendRecord) Validate() error

Validate checks the given object for invalid values.

type FrontendSelectorRecord

type FrontendSelectorRecord struct {
	Weight       int           `json:"weight,omitempty"`
	Domain       string        `json:"domain,omitempty"`
	PathPrefix   string        `json:"path-prefix,omitempty"`
	SslCert      string        `json:"ssl-cert,omitempty"`
	ServicePort  int           `json:"port,omitempty"`
	FrontendPort int           `json:"frontend-port,omitempty"`
	Private      bool          `json:"private,omitempty"`
	Users        []UserRecord  `json:"users,omitempty"`
	RewriteRules []RewriteRule `json:"rewrite-rules,omitempty"`
}

func (FrontendSelectorRecord) Validate

func (r FrontendSelectorRecord) Validate() error

Validate checks the given object for invalid values.

type RewriteRule

type RewriteRule struct {
	PathPrefix       string `json:"path-prefix,omitempty"`        // Add this to the start of the request path.
	RemovePathPrefix string `json:"remove-path-prefix,omitempty"` // Remove this from the start of the request path.
	Domain           string `json:"domain,omitempty"`             // Redirect to this domain
}

func (RewriteRule) Validate

func (r RewriteRule) Validate() error

Validate checks the given object for invalid values.

type UserRecord

type UserRecord struct {
	Name         string `json:"user"`
	PasswordHash string `json:"pwhash"`
}

func (UserRecord) Validate

func (r UserRecord) Validate() error

Validate checks the given object for invalid values.

Directories

Path Synopsis
deps
github.com/juju/errgo
The errgo package provides a way to create and diagnose errors.
The errgo package provides a way to create and diagnose errors.
github.com/juju/errgo/errors
The errors package provides a way to create and diagnose errors.
The errors package provides a way to create and diagnose errors.

Jump to

Keyboard shortcuts

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