endpoint

package
v2.0.3+incompatible Latest Latest
Warning

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

Go to latest
Published: May 9, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint struct {

	// Support scheduled task for this endpoint
	Timeout
	// contains filtered or unexported fields
}

Endpoint structure represents a single remote endpoint

func (*Endpoint) AverageLatency

func (e *Endpoint) AverageLatency() time.Duration

AverageLatency returns the endpoint's average latency

func (*Endpoint) EstDelTime

func (e *Endpoint) EstDelTime() time.Time

EstDelTime returns the expected time this endpoint will have delivered all of its events

func (*Endpoint) EventChan

func (e *Endpoint) EventChan() chan<- transports.Event

EventChan returns the event channel transports should send events through

func (*Endpoint) Init

func (e *Endpoint) Init()

Init prepares the internal Element structures for InternalList and prepares the pending payload structures

func (*Endpoint) IsActive

func (e *Endpoint) IsActive() bool

IsActive returns true if this Endpoint is active

func (*Endpoint) IsAlive

func (e *Endpoint) IsAlive() bool

IsAlive returns true if this endpoint is not failed or closing

func (*Endpoint) IsClosing

func (e *Endpoint) IsClosing() bool

IsClosing returns true if this Endpoint is closing down

func (*Endpoint) IsFailed

func (e *Endpoint) IsFailed() bool

IsFailed returns true if this endpoint has been marked as failed

func (*Endpoint) IsIdle

func (e *Endpoint) IsIdle() bool

IsIdle returns true if this Endpoint is idle (newly created and unused)

func (*Endpoint) IsPinging

func (e *Endpoint) IsPinging() bool

IsPinging returns true if the endpoint is still awaiting for a PONG response to a previous Ping request

func (*Endpoint) IsWarming

func (e *Endpoint) IsWarming() bool

IsWarming returns whether the endpoint is warming up or not (slow-start)

func (*Endpoint) LineCount

func (e *Endpoint) LineCount() int64

LineCount returns the endpoint's published line count

func (*Endpoint) Next

func (e *Endpoint) Next() *Endpoint

Next returns the next endpoint in the ordered list

func (*Endpoint) NumPending

func (e *Endpoint) NumPending() int

NumPending returns the number of pending payloads on this endpoint

func (*Endpoint) Pool

func (e *Endpoint) Pool() *addresspool.Pool

Pool returns the associated address pool This implements part of the transports.Proxy interface for callbacks

func (*Endpoint) Prev

func (e *Endpoint) Prev() *Endpoint

Prev returns the previous endpoint in the ordered list

func (*Endpoint) PullBackPending

func (e *Endpoint) PullBackPending() []*payload.Payload

PullBackPending returns all queued payloads back to the publisher Called when a failure happens

func (*Endpoint) ReduceLatency

func (e *Endpoint) ReduceLatency()

ReduceLatency artificially reduces the recorded latency of the endpoint. It is used to ensure that really bad endpoints do not get ignored forever, as if events are never sent to it, the latency is never recalculated

func (*Endpoint) ReloadConfig

func (e *Endpoint) ReloadConfig(config *config.Network, finishOnFail bool) bool

ReloadConfig submits a new configuration to the transport, and returns true if the transports requested that it be restarted in order for the configuration to take effect

func (*Endpoint) SendPing

func (e *Endpoint) SendPing() error

SendPing sends a ping message to the transport that it sends to the remote endpoint to ensure its connection is still available. Some transports may simply do nothing and Pong() back immediately if they are managed as such.

func (*Endpoint) Server

func (e *Endpoint) Server() string

Server returns the server string from the configuration file that this endpoint is associated with

type Observer

type Observer interface {
	// OnAck is called when an acknowledgement response is received
	// The payload is given and the second argument is true if this ack is the
	// first ack for this payload
	OnAck(*Endpoint, *payload.Payload, bool, int)
	// OnFail is called when the endpoint fails
	OnFail(*Endpoint)
	// OnFinished is called when an endpoint finishes and is removed
	// Returning false prevents the endpoint from being recreated, which it will
	// be if it still exists in the configuration
	OnFinish(*Endpoint) bool
	// OnPong is called when a pong response is received from the endpoint
	OnPong(*Endpoint)
	// OnStarted is called when an endpoint starts up and is ready
	OnStarted(*Endpoint)
}

Observer is the interface implemented by the observer of the sink and will receive callbacks on status changes it needs to action

type Sink

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

Sink structure contains the control channels that each endpoint will utilise. The newEndpoint method attaches new endpoints to this

func NewSink

func NewSink(config *config.Network) *Sink

NewSink initialises a new message sink for endpoints

func (*Sink) APINavigatable

func (s *Sink) APINavigatable() admin.APINavigatable

APINavigatable returns an APINavigatable that exposes status information for this sink It should be called BEFORE adding any endpoints as existing endpoints will not automatically become monitored

func (*Sink) AddEndpoint

func (s *Sink) AddEndpoint(server string, addressPool *addresspool.Pool, finishOnFail bool) *Endpoint

AddEndpoint initialises a new endpoint for a given server entry and adds it to the back of the list of endpoints

func (*Sink) AddEndpointAfter

func (s *Sink) AddEndpointAfter(server string, addressPool *addresspool.Pool, finishOnFail bool, after *Endpoint) *Endpoint

AddEndpointAfter initialises a new endpoint for a given server entry and adds it in the list to the position after the given endpoint. If the given endpoint is nil it is added at the front

func (*Sink) CanQueue

func (s *Sink) CanQueue() bool

CanQueue returns true if there are active endpoints ready to receive events

func (*Sink) ClearTimeout

func (s *Sink) ClearTimeout(timeout *Timeout)

ClearTimeout removes a timeout structure

func (*Sink) Count

func (s *Sink) Count() int

Count returns the number of associated endpoints present

func (*Sink) EventChan

func (s *Sink) EventChan() <-chan transports.Event

EventChan returns the event channel Status events and messages from endpoints pass through here for processing

func (*Sink) FindEndpoint

func (s *Sink) FindEndpoint(server string) *Endpoint

FindEndpoint returns the endpoint associated with the given server entry, or nil if no endpoint is associated

func (*Sink) ForceFailure

func (s *Sink) ForceFailure(endpoint *Endpoint)

ForceFailure forces an endpoint to fail

func (*Sink) Front

func (s *Sink) Front() *Endpoint

Front returns the first endpoint currently active

func (*Sink) MoveEndpointAfter

func (s *Sink) MoveEndpointAfter(endpoint *Endpoint, after *Endpoint)

MoveEndpointAfter ensures the endpoint specified appears directly after the requested endpoint, or at the beginning if nil

func (*Sink) ProcessEvent

func (s *Sink) ProcessEvent(event transports.Event, observer Observer)

ProcessEvent performs the necessary processing of events

func (*Sink) ProcessTimeouts

func (s *Sink) ProcessTimeouts()

ProcessTimeouts processes all pending timeouts

func (*Sink) QueuePayload

func (s *Sink) QueuePayload(payload *payload.Payload) (*Endpoint, error)

QueuePayload locates the best endpoint to send the events to, and attempts to queue the events on that endpoint. Returns the best endpoint and any error that occurred sending the events.

func (*Sink) RegisterTimeout

func (s *Sink) RegisterTimeout(timeout *Timeout, duration time.Duration, timeoutFunc TimeoutFunc)

RegisterTimeout registers a timeout structure with a timeout and timeout callback

func (*Sink) ReloadConfig

func (s *Sink) ReloadConfig(config *config.Network)

ReloadConfig loads in a new configuration, endpoints will be shutdown if they are no longer in the configuration

func (*Sink) Shutdown

func (s *Sink) Shutdown()

Shutdown signals all associated endpoints to begin shutting down

func (*Sink) ShutdownEndpoint

func (s *Sink) ShutdownEndpoint(server string) bool

ShutdownEndpoint requests the endpoint associated with the given server entry to shutdown, returning false if the endpoint could not be shutdown

func (*Sink) TimeoutChan

func (s *Sink) TimeoutChan() <-chan time.Time

TimeoutChan returns a channel which will receive the current time when the next endpoint hits its registered timeout

type Timeout

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

Timeout holds timeout information for use with the sink timeout channel It can be embedded into any other structure that requires timeout support

func (*Timeout) InitTimeout

func (t *Timeout) InitTimeout()

InitTimeout initialises the timeout structure

type TimeoutFunc

type TimeoutFunc func()

TimeoutFunc describes a callback that can be registered with the sink timer channel

Jump to

Keyboard shortcuts

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