server

package
v0.0.0-...-27a864e Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAddress = "127.0.0.1:63412"
	DefaultPrefix  = "/akins.org/onedari"
)

Variables

View Source
var (
	DefaultEndpoints     = []string{"http://127.0.0.1:2379", "http://127.0.0.1:4001"}
	MissingLabelError    = errors.New("must have at least one label")
	MissingQueryError    = errors.New("must have at least one label query")
	InvalidIDError       = errors.New("invalid ID")
	EmptyNodeError       = errors.New("empty node")
	InvalidInstanceError = errors.New("invalid instance")
)

Functions

func JSON

func JSON(w http.ResponseWriter, code int, v interface{}) error

func LabelMatches

func LabelMatches(labels, query map[string]string) bool

LabelMatches returns true if all the labels in query match label.

func ParseBody

func ParseBody(r *http.Request, v interface{}) error

func QueryFromRequest

func QueryFromRequest(r *http.Request) (map[string]string, error)

func UpSelector

func UpSelector(i *api.Instance) bool

UpSelector returns true for instances that are "up".

Types

type HTTPError

type HTTPError struct {
	Error   string `json:"error"`
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type InstanceSelectorFunc

type InstanceSelectorFunc func(*api.Instance) bool

func LabelSelector

func LabelSelector(query map[string]string) InstanceSelectorFunc

LabelSelector returns true if the given query matches the instance.

func NodeSelector

func NodeSelector(n *api.Node) InstanceSelectorFunc

NodeSelector returns true only if this instance is on the given node. This is a bit of a hack because of the naive search implementation we use.

type OptionFunc

type OptionFunc func(*Server) error

func Address

func Address(addr string) OptionFunc

func EtcdEndpoints

func EtcdEndpoints(endpoints []string) OptionFunc

func Prefix

func Prefix(p string) OptionFunc

type Server

type Server struct {
	Node *api.Node
	// contains filtered or unexported fields
}

func New

func New(node *api.Node, options ...OptionFunc) (*Server, error)

func (*Server) ListInstances

func (s *Server) ListInstances(selectors ...InstanceSelectorFunc) ([]*api.Instance, error)

ListInstances fetches all instances optionally using the query as a selector.

func (*Server) Run

func (s *Server) Run() error

func (*Server) SaveNode

func (s *Server) SaveNode() error

Jump to

Keyboard shortcuts

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