receiver

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RELOAD_HOLD_DOWN = 5 * time.Second // Reload at worst every 5 seconds
)

Variables

This section is empty.

Functions

func FetchState

func FetchState(url string) (*catalog.ServicesState, error)

Used to fetch the current state from a Sidecar endpoint, usually on startup of this process, when the currentState is empty.

func ShouldNotify

func ShouldNotify(oldStatus int, newStatus int) bool

Check all the state transitions and only update HAproxy when a change will affect service availability.

func UpdateHandler

func UpdateHandler(response http.ResponseWriter, req *http.Request, rcvr *Receiver)

Receives POSTed state updates from a Sidecar instance

Types

type ApiErrors

type ApiErrors struct {
	Errors []string `json:"errors"`
}

type Receiver

type Receiver struct {
	StateLock      sync.Mutex
	ReloadChan     chan time.Time
	CurrentState   *catalog.ServicesState
	LastSvcChanged *service.Service
	OnUpdate       func(state *catalog.ServicesState)
	Looper         director.Looper
}

func NewReceiver added in v1.3.0

func NewReceiver(capacity int, onUpdate func(state *catalog.ServicesState)) *Receiver

func (*Receiver) EnqueueUpdate

func (rcvr *Receiver) EnqueueUpdate()

EnqueueUpdate puts a new timestamp on the update channel, to be processed in a goroutine that runs the ProcessUpdates function.

func (*Receiver) FetchInitialState

func (rcvr *Receiver) FetchInitialState(stateUrl string) error

FetchInitialState is used at startup to bootstrap initial state from Sidecar.

func (*Receiver) ProcessUpdates

func (rcvr *Receiver) ProcessUpdates()

ProcessUpdates loops forever, processing updates to the state. By the time we get here, the HTTP UpdateHandler has already set the CurrentState to the newest state we know about. Here we'll try to group updates together to prevent repeatedly updating on a series of events that arrive in a row.

Jump to

Keyboard shortcuts

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