lookaside

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2017 License: MIT Imports: 10 Imported by: 0

README

gRPC Lookaside Load Balancer

This is an implementation of a lookaside (or external/one-arm) load balancer as detailed in the gRPC documentation for load balancing that uses Consul for service discovery. It supports multiple types of load-balancing (random, round-robin, hash) and periodic address refreshes.

Usage

Unsurprisingly, this service uses a gRPC-based interface to request addresses (see proto for services and messages).

CLI

The application has a simple CLI interface and supports the following arguments and environment variable configurations:

--bind, b

The address that the service will bind to in {host}:{port} format. Defaults to :3000.

--consul, c [$CONSUL_ADDRESS]

The address of the Consul agent used for service discovery. Defaults to 127.0.0.1:8500 (local agent).

--datacenter, d [$CONSUL_DATACENTER]

The Consul datacenter to query for services. Defaults to dc1.

--refresh, r [$REFRESH]

Time, in seconds, between service address list refreshes. Defaults to 10 seconds.

Building

You'll need a working install of the Go programming language to compile the go code and the GNU make tool for running the builds. Once everything is installed and setup, just run:

$ make

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Router

type Router struct {
	Addresses       []string
	LastRefresh     time.Time
	RefreshInterval float64
	// contains filtered or unexported fields
}

Router is a type that contains a set of addresses and methods for resolving them based on use input

func (*Router) NeedsRefresh

func (r *Router) NeedsRefresh() bool

func (*Router) ResolveHash

func (r *Router) ResolveHash(data []byte) (string, error)

ResolveHash returns an address bound to the hash provided, or picks a new one and binds it

func (*Router) ResolveRandom

func (r *Router) ResolveRandom() (string, error)

ResolveRandom returns a random address

func (*Router) ResolveRoundRobin

func (r *Router) ResolveRoundRobin() (string, error)

ResolveRoundRobin returns the next address, looping back to the first when reaching the end

type Server

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

func NewServer

func NewServer(c *cli.Context) *Server

func (*Server) Resolve

func (s *Server) Resolve(ctx context.Context, input *pb.Request) (*pb.Response, error)

Directories

Path Synopsis
Package _proto is a generated protocol buffer package.
Package _proto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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