Documentation ¶
Index ¶
Constants ¶
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 ¶
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 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 Subscriptions []string }
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 ¶
FetchInitialState is used at startup to bootstrap initial state from Sidecar.
func (*Receiver) IsSubscribed ¶
IsSubscribed allows a receiver to filter incoming events by service name
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.