sd

package
v0.0.0-...-7f749bc Latest Latest
Warning

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

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

Documentation

Overview

Package sd defines some interfaces and implementations for service discovery

Index

Constants

This section is empty.

Variables

View Source
var ErrNoHosts = errors.New("no hosts available")

ErrNoHosts is the error the balancer must return when there are 0 hosts ready

Functions

This section is empty.

Types

type Balancer

type Balancer interface {
	Host() (string, error)
}

Balancer applys a balancing stategy in order to select the backend host to be used

func NewRandomLB

func NewRandomLB(subscriber Subscriber, seed int64) Balancer

NewRandomLB returns a new balancer using a pseudo-random strategy

func NewRoundRobinLB

func NewRoundRobinLB(subscriber Subscriber) Balancer

NewRoundRobinLB returns a new balancer using a round robin strategy

type FixedSubscriber

type FixedSubscriber []string

FixedSubscriber has a constant set of backend hosts and they never get updated

func (FixedSubscriber) Hosts

func (s FixedSubscriber) Hosts() ([]string, error)

Hosts implements the subscriber interface

type Subscriber

type Subscriber interface {
	Hosts() ([]string, error)
}

Subscriber keeps the set of backend hosts up to date

func FixedSubscriberFactory

func FixedSubscriberFactory(cfg *config.Backend) Subscriber

FixedSubscriberFactory builds a FixedSubscriber with the received config

type SubscriberFactory

type SubscriberFactory func(*config.Backend) Subscriber

SubscriberFactory builds subscribers with the received config

Directories

Path Synopsis
Package dnssrv defines some implementations for a dns based service discovery
Package dnssrv defines some implementations for a dns based service discovery

Jump to

Keyboard shortcuts

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