Documentation ¶
Index ¶
- Constants
- type MockReporter
- func (m *MockReporter) OnDataReceived(ctx context.Context) context.Context
- func (m *MockReporter) OnDebugf(template string, args ...interface{})
- func (m *MockReporter) OnMetricsProcessed(ctx context.Context, numReceivedMetricPoints int, err error)
- func (m *MockReporter) OnTranslationError(ctx context.Context, err error)
- func (m *MockReporter) WaitAllOnMetricsProcessedCalls()
- type Reporter
- type Server
Constants ¶
const ( // TCPIdleTimeoutDefault is the default timeout for idle TCP connections. TCPIdleTimeoutDefault = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MockReporter ¶
type MockReporter struct {
// contains filtered or unexported fields
}
MockReporter provides a Reporter that provides some useful functionalities for tests (eg.: wait for certain number of messages).
func NewMockReporter ¶
func NewMockReporter(expectedOnMetricsProcessedCalls int) *MockReporter
NewMockReporter returns a new instance of a MockReporter.
func (*MockReporter) OnDataReceived ¶
func (m *MockReporter) OnDataReceived(ctx context.Context) context.Context
func (*MockReporter) OnDebugf ¶
func (m *MockReporter) OnDebugf(template string, args ...interface{})
func (*MockReporter) OnMetricsProcessed ¶
func (m *MockReporter) OnMetricsProcessed(ctx context.Context, numReceivedMetricPoints int, err error)
func (*MockReporter) OnTranslationError ¶
func (m *MockReporter) OnTranslationError(ctx context.Context, err error)
func (*MockReporter) WaitAllOnMetricsProcessedCalls ¶
func (m *MockReporter) WaitAllOnMetricsProcessedCalls()
WaitAllOnMetricsProcessedCalls blocks until the number of expected calls specified at creation of the reporter is completed.
type Reporter ¶
type Reporter interface { // OnDataReceived is called when a message or request is received from // a client. The returned context should be used in other calls to the same // reporter instance. The caller code should include a call to end the // returned span. OnDataReceived(ctx context.Context) context.Context // OnTranslationError is used to report a translation error from original // format to the internal format of the Collector. The context // passed to it should be the ones returned by OnDataReceived. OnTranslationError(ctx context.Context, err error) // OnMetricsProcessed is called when the received data is passed to next // consumer on the pipeline. The context passed to it should be the // one returned by OnDataReceived. The error should be error returned by // the next consumer - the reporter is expected to handle nil error too. OnMetricsProcessed( ctx context.Context, numReceivedMetricPoints int, err error) // OnDebugf allows less structured reporting for debugging scenarios. OnDebugf( template string, args ...interface{}) }
Reporter is used to report (via zPages, logs, metrics, etc) the events happening when the Server is receiving and processing data.
type Server ¶
type Server interface { // ListenAndServe is a blocking call that starts to listen for client messages // on the specific transport, and prepares the message to be processed by // the Parser and passed to the next consumer. ListenAndServe( p protocol.Parser, mc consumer.Metrics, r Reporter, ) error // Close stops any running ListenAndServe, however, it waits for any // data already received to be parsed and sent to the next consumer. Close() error }
Server abstracts the type of transport being used and offer an interface to handle serving clients over that transport.
func NewTCPServer ¶
NewTCPServer creates a transport.Server using TCP as its transport.
func NewUDPServer ¶
NewUDPServer creates a transport.Server using UDP as its transport.