Documentation ¶
Index ¶
- Variables
- func SortContainerMetrics(messages []*events.ContainerMetric) []*events.ContainerMetric
- func SortRecent(messages []*events.LogMessage) []*events.LogMessage
- type Consumer
- func (cnsmr *Consumer) Close() error
- func (cnsmr *Consumer) ContainerMetrics(appGuid string, authToken string) ([]*events.ContainerMetric, error)
- func (cnsmr *Consumer) Firehose(subscriptionId string, authToken string, outputChan chan<- *events.Envelope, ...)
- func (cnsmr *Consumer) FirehoseWithoutReconnect(subscriptionId string, authToken string, outputChan chan<- *events.Envelope) error
- func (cnsmr *Consumer) RecentLogs(appGuid string, authToken string) ([]*events.LogMessage, error)
- func (cnsmr *Consumer) SetDebugPrinter(debugPrinter DebugPrinter)
- func (cnsmr *Consumer) SetOnConnectCallback(cb func())
- func (cnsmr *Consumer) Stream(appGuid string, authToken string, outputChan chan<- *events.Envelope, ...)
- func (cnsmr *Consumer) StreamWithoutReconnect(appGuid string, authToken string, outputChan chan<- *events.Envelope) error
- func (cnsmr *Consumer) TailingLogs(appGuid string, authToken string, outputChan chan<- *events.LogMessage, ...)
- func (cnsmr *Consumer) TailingLogsWithoutReconnect(appGuid string, authToken string, outputChan chan<- *events.LogMessage) 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 ErrNotFound = errors.New("/recent path not found or has issues") ErrBadResponse = errors.New("bad server response") ErrBadRequest = errors.New("bad client request") ErrLostConnection = errors.New("remote server terminated connection unexpectedly") )
Functions ¶
func SortContainerMetrics ¶
func SortContainerMetrics(messages []*events.ContainerMetric) []*events.ContainerMetric
SortContainerMetrics sorts a slice of containerMetrics by InstanceIndex.
The input slice is sorted; the return value is simply a pointer to the same slice.
func SortRecent ¶
func SortRecent(messages []*events.LogMessage) []*events.LogMessage
SortRecent sorts a slice of LogMessages by timestamp. The sort is stable, so messages with the same timestamp are sorted in the order that they are received.
The input slice is sorted; the return value is simply a pointer to the same slice.
Types ¶
type Consumer ¶
Consumer represents the actions that can be performed against traffic controller.
func NewConsumer ¶
func NewConsumer(trafficControllerUrl string, tlsConfig *tls.Config, proxy func(*http.Request) (*url.URL, error)) *Consumer
NewConsumer creates a new consumer to a traffic controller.
func (*Consumer) ContainerMetrics ¶
func (cnsmr *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 (cnsmr *Consumer) Firehose(subscriptionId string, authToken string, outputChan chan<- *events.Envelope, errorChan chan<- error, stopChan chan struct{})
Firehose behaves exactly as FirehoseWithoutReconnect, except that it retries 5 times if the connection to the remote server is lost.
func (*Consumer) FirehoseWithoutReconnect ¶
func (cnsmr *Consumer) FirehoseWithoutReconnect(subscriptionId string, authToken string, outputChan chan<- *events.Envelope) error
FirehoseWithoutReconnect 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.
If you wish to be able to terminate the listen early, run FirehoseWithoutReconnect in a Goroutine and call Close() when you are finished listening.
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.
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 SortRecent method is provided to sort the data returned by this method.
func (*Consumer) SetDebugPrinter ¶
func (cnsmr *Consumer) SetDebugPrinter(debugPrinter DebugPrinter)
SetDebugPrinter enables logging of the websocket handshake.
func (*Consumer) SetOnConnectCallback ¶
func (cnsmr *Consumer) SetOnConnectCallback(cb func())
SetOnConnectCallback sets a callback function to be called with the websocket connection is established.
func (*Consumer) Stream ¶
func (cnsmr *Consumer) Stream(appGuid string, authToken string, outputChan chan<- *events.Envelope, errorChan chan<- error, stopChan chan struct{})
Stream behaves exactly as StreamWithoutReconnect, except that it retries 5 times if the connection to the remote server is lost.
func (*Consumer) StreamWithoutReconnect ¶
func (cnsmr *Consumer) StreamWithoutReconnect(appGuid string, authToken string, outputChan chan<- *events.Envelope) error
StreamWithoutReconnect listens indefinitely for all log and event messages.
If you wish to be able to terminate the listen early, run StreamWithoutReconnect in a Goroutine and call Close() when you are finished listening.
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.
func (*Consumer) TailingLogs ¶
func (cnsmr *Consumer) TailingLogs(appGuid string, authToken string, outputChan chan<- *events.LogMessage, errorChan chan<- error, stopChan chan struct{})
TailingLogs behaves exactly as TailingLogsWithoutReconnect, except that it retries 5 times if the connection to the remote server is lost and returns all errors from each attempt on errorChan.
func (*Consumer) TailingLogsWithoutReconnect ¶
func (cnsmr *Consumer) TailingLogsWithoutReconnect(appGuid string, authToken string, outputChan chan<- *events.LogMessage) error
TailingLogsWithoutReconnect listens indefinitely for log messages only; other event types are dropped.
If you wish to be able to terminate the listen early, run TailingLogsWithoutReconnect in a Goroutine and call Close() when you are finished listening.
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.
type DebugPrinter ¶
type DebugPrinter interface {
Print(title, dump string)
}
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package events is a generated protocol buffer package.
|
Package events is a generated protocol buffer package. |