backplane

package
v0.0.0-...-f91f8e9 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2016 License: MIT Imports: 7 Imported by: 1

Documentation

Overview

Package backplane contains client API bindings for Backplane, a distributed hosted load balancer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	ID                string    `json:"ID"`
	Owner             string    `json:"Owner"`
	RawLabels         string    `json:"RawLabels"`
	Load              int       `json:"Load"`
	RemoteAddr        string    `json:"RemoteAddr"`
	ConnectedAt       time.Time `json:"ConnectedAt"`
	Location          Location  `json:"Location"`
	RequestsPerSecond int       `json:"RequestsPerSecond"`
	State             string    `json:"State"`
}

Backend is a HTTP web server connected to Backplane via the backplane agent paired to it.

type Client

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

Client is the API client that performs actions against the Backplane API server.

func New

func New(token string) (*Client, error)

New creates a new API client with the given token

func (*Client) API

func (c *Client) API(method, path string, parameters map[string]string, postData interface{}, out interface{}) error

API is a generic json-encoding like function that allows access to any backplane.io API call.

See the implementation of Client.Query and Client.Shape for usage information.

func (*Client) GenToken

func (c *Client) GenToken() (string, error)

GenToken creates a new Backplane API token for a future backplane Agent to user.

func (*Client) Query

func (c *Client) Query() (*QueryResponse, error)

Query fetches infornation about all Endpoints, Routes and Backends registered to your account.

func (*Client) Route

func (c *Client) Route(pattern string, labels map[string]string) (*Route, error)

Route creates a new Route on Backplane for the given pattern and label selector.

func (*Client) Shape

func (c *Client) Shape(endpoint string, weights map[string]int) error

Shape changes the weights on Routes of a given Endpoint.

type Endpoint

type Endpoint struct {
	Pattern   string    `json:"Pattern"`
	Owner     string    `json:"Owner"`
	CreatedAt time.Time `json:"CreatedAt"`
	Routes    []Route   `json:"Routes"`
}

Endpoint looks like example.com api.example.com, or www.example.com/blog and are matched to requests with URLs that most closely match them.

type Location

type Location struct {
	Latitude      float64 `json:"Latitude"`
	Longitude     float64 `json:"Longitude"`
	CityName      string  `json:"CityName"`
	CountryCode   string  `json:"CountryCode"`
	CountryName   string  `json:"CountryName"`
	ContinentCode string  `json:"ContinentCode"`
	ContinentName string  `json:"ContinentName"`
	RegionCode    string  `json:"RegionCode"`
	RegionName    string  `json:"RegionName"`
}

Location represents a geographic location.

type QueryResponse

type QueryResponse struct {
	Token     string     `json:"Token"`
	Endpoints []Endpoint `json:"Endpoints"`
	Backends  []Backend  `json:"Backends"`
}

QueryResponse matches the output of www.backplane.io/q

type Route

type Route struct {
	ID          string   `json:"ID,omitempty"`
	RawSelector string   `json:"RawSelector"`
	Weight      int      `json:"Weight,omitempty"`
	Strategy    string   `json:"Strategy,omitempty"`
	Backends    []string `json:"Backends,omitempty"`
}

Route is how Backplane determines how to get traffic from an Endpoint to a Backend. Routes are identified by their routeID, which looks like route000. Routes are chosen by their Endpoint based on their weight.

Once a Route has been chosen Backplane will then choose a Backend.

Jump to

Keyboard shortcuts

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