Documentation
¶
Index ¶
- Variables
- type Consumer
- func (c *Consumer) Close() error
- func (c *Consumer) Closed() bool
- func (c *Consumer) ContainerMetrics(appGuid string, authToken string) ([]*events.ContainerMetric, error)
- func (c *Consumer) Firehose(subscriptionId string, authToken string) (<-chan *events.Envelope, <-chan error)
- func (c *Consumer) FirehoseWithoutReconnect(subscriptionId string, authToken string) (<-chan *events.Envelope, <-chan error)
- func (c *Consumer) RecentLogs(appGuid string, authToken string) ([]*events.LogMessage, error)
- func (c *Consumer) SetDebugPrinter(debugPrinter noaa.DebugPrinter)
- func (c *Consumer) SetIdleTimeout(idleTimeout time.Duration)
- func (c *Consumer) SetOnConnectCallback(cb func())
- func (c *Consumer) Stream(appGuid string, authToken string) (outputChan <-chan *events.Envelope, errorChan <-chan error)
- func (c *Consumer) StreamWithoutReconnect(appGuid string, authToken string) (<-chan *events.Envelope, <-chan error)
- func (c *Consumer) TailingLogs(appGuid, authToken string) (<-chan *events.LogMessage, <-chan error)
- func (c *Consumer) TailingLogsWithoutReconnect(appGuid string, authToken string) (<-chan *events.LogMessage, <-chan error)
- type DebugPrinter
Constants ¶
This section is empty.
Variables ¶
var ( // KeepAlive sets the interval between keep-alive messages sent by the client to loggregator. KeepAlive = 25 * time.Second ErrNotOK = errors.New("unknown issue when making HTTP request to Loggregator") ErrNotFound = ErrNotOK // NotFound isn't an accurate description of how this is used; please use ErrNotOK instead ErrBadResponse = errors.New("bad server response") ErrBadRequest = errors.New("bad client request") ErrLostConnection = errors.New("remote server terminated connection unexpectedly") )
Functions ¶
This section is empty.
Types ¶
type Consumer ¶
type Consumer struct {
// contains filtered or unexported fields
}
Consumer represents the actions that can be performed against traffic controller. See sync.go and async.go for traffic controller access methods.
func New ¶
func New(trafficControllerUrl string, tlsConfig *tls.Config, proxy func(*http.Request) (*url.URL, error)) *Consumer
New creates a new consumer to a traffic controller.
func (*Consumer) Close ¶
Close terminates the websocket connection to traffic controller. It will return an error if it has problems closing the connection. If there is no connection to close, the consumer will be closed so that no further operations will be performed (including any pending retries), and an error declaring "connection does not exist" will be returned.
func (*Consumer) ContainerMetrics ¶
func (c *Consumer) ContainerMetrics(appGuid string, authToken string) ([]*events.ContainerMetric, error)
ContainerMetrics connects to traffic controller via its 'containermetrics' http(s) endpoint and returns the most recent messages for an app. The returned metrics will be sorted by InstanceIndex.
func (*Consumer) Firehose ¶
func (c *Consumer) Firehose(subscriptionId string, authToken string) (<-chan *events.Envelope, <-chan error)
Firehose streams all data. All clients with the same subscriptionId will receive a proportionate share of the message stream. Each pool of clients will receive the entire stream.
Messages are presented in the order received from the loggregator server. Chronological or other ordering is not guaranteed. It is the responsibility of the consumer of these channels to provide any desired sorting mechanism.
Whenever an error is encountered, the error will be sent down the error channel and Firehose will attempt to reconnect up to 5 times. After five failed reconnection attempts, Firehose will give up and close the error and Envelope channels.
func (*Consumer) FirehoseWithoutReconnect ¶
func (c *Consumer) FirehoseWithoutReconnect(subscriptionId string, authToken string) (<-chan *events.Envelope, <-chan error)
FirehoseWithoutReconnect functions identically to Firehose but without any reconnect attempts when errors occur.
func (*Consumer) RecentLogs ¶
RecentLogs connects to traffic controller via its 'recentlogs' http(s) endpoint and returns a slice of recent messages. It does not guarantee any order of the messages; they are in the order returned by traffic controller.
The noaa.SortRecent function is provided to sort the data returned by this method.
func (*Consumer) SetDebugPrinter ¶
func (c *Consumer) SetDebugPrinter(debugPrinter noaa.DebugPrinter)
SetDebugPrinter sets the websocket connection to write debug information to debugPrinter.
func (*Consumer) SetIdleTimeout ¶
func (*Consumer) SetOnConnectCallback ¶
func (c *Consumer) SetOnConnectCallback(cb func())
SetOnConnectCallback sets a callback function to be called with the websocket connection is established.
func (*Consumer) Stream ¶
func (c *Consumer) Stream(appGuid string, authToken string) (outputChan <-chan *events.Envelope, errorChan <-chan error)
Stream listens indefinitely for all log and event messages.
Messages are presented in the order received from the loggregator server. Chronological or other ordering is not guaranteed. It is the responsibility of the consumer of these channels to provide any desired sorting mechanism.
Whenever an error is encountered, the error will be sent down the error channel and Stream will attempt to reconnect up to 5 times. After five failed reconnection attempts, Stream will give up and close the error and Envelope channels.
func (*Consumer) StreamWithoutReconnect ¶
func (c *Consumer) StreamWithoutReconnect(appGuid string, authToken string) (<-chan *events.Envelope, <-chan error)
StreamWithoutReconnect functions identically to Stream but without any reconnect attempts when errors occur.
func (*Consumer) TailingLogs ¶
func (c *Consumer) TailingLogs(appGuid, authToken string) (<-chan *events.LogMessage, <-chan error)
TailingLogs listens indefinitely for log messages only; other event types are dropped. Whenever an error is encountered, the error will be sent down the error channel and TailingLogs will attempt to reconnect up to 5 times. After five failed reconnection attempts, TailingLogs will give up and close the error and LogMessage channels.
If c is closed, the returned channels will both be closed.
Errors must be drained from the returned error channel for it to continue retrying; if they are not drained, the connection attempts will hang.
func (*Consumer) TailingLogsWithoutReconnect ¶
func (c *Consumer) TailingLogsWithoutReconnect(appGuid string, authToken string) (<-chan *events.LogMessage, <-chan error)
TailingLogsWithoutReconnect functions identically to TailingLogs but without any reconnect attempts when errors occur.
type DebugPrinter ¶
type DebugPrinter interface {
Print(title, dump string)
}
DebugPrinter is a type which handles printing debug information.