handler

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2019 License: Apache-2.0 Imports: 17 Imported by: 8

README

Interfaces

  • Handler processes aggregated metrics alongside their policies.
  • Writer encodes and buffers data before writing them to backends.
  • Router routes encoded data to the corresponding backend queues.
  • Queue queues up encoded data and asynchronously forwards them to backend servers.

How the interfaces fit together

Client uses Handler to create new Writers, which encodes data internally and flushes them when the internal buffer is large enough. The flushed buffer is then routed to different backend Queues via the Router and eventually sent to the backend servers.

Optimizations

  • In order to make sure we don't encode data more times than necessary, the backend queues are grouped by their sharding ids so that if two backends share the same sharding id (including the sharding hash type and the total number of shards), they belong to the same group which receives ref-counted buffers from a single writer so that aggregated metrics are only encoded once per sharding function to save CPU cycles.

  • In order to reduce lock contention among different aggregator lists, the writers returned from the handlers are intentionally thread-unsafe. Each aggregator list holds on to a writer it creates when the list is created, and uses the writer to write data in a flush. This is okay because a list only performs at most one flush at any given time. As a result, the lists writes data independently and don't contend with each other when flushing at the same time.

Documentation

Overview

Package handler is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlushHandlerConfiguration

type FlushHandlerConfiguration struct {
	Handlers []flushHandlerConfiguration `yaml:"handlers" validate:"nonzero"`
}

FlushHandlerConfiguration configures flush handlers.

func (FlushHandlerConfiguration) NewHandler

func (c FlushHandlerConfiguration) NewHandler(
	cs client.Client,
	instrumentOpts instrument.Options,
) (Handler, error)

NewHandler creates a new flush handler based on the configuration.

type Handler

type Handler interface {
	// NewWriter creates a new writer for writing aggregated metrics and policies.
	NewWriter(scope tally.Scope) (writer.Writer, error)

	// Close closes the handler.
	Close()
}

Handler handles aggregated metrics alongside their policies.

func NewBlackholeHandler

func NewBlackholeHandler() Handler

NewBlackholeHandler creates a new blackhole handler.

func NewBroadcastHandler

func NewBroadcastHandler(handlers []Handler) Handler

NewBroadcastHandler creates a new Handler that broadcasts incoming data to a list of handlers.

func NewLoggingHandler

func NewLoggingHandler(logger log.Logger) Handler

NewLoggingHandler creates a new logging handler.

func NewProtobufHandler added in v0.5.0

func NewProtobufHandler(
	p producer.Producer,
	hashType sharding.HashType,
	opts writer.Options,
) Handler

NewProtobufHandler creates a new protobuf handler.

type MockHandler

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

MockHandler is a mock of Handler interface

func NewMockHandler

func NewMockHandler(ctrl *gomock.Controller) *MockHandler

NewMockHandler creates a new mock instance

func (*MockHandler) Close

func (m *MockHandler) Close()

Close mocks base method

func (*MockHandler) EXPECT

func (m *MockHandler) EXPECT() *MockHandlerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockHandler) NewWriter

func (m *MockHandler) NewWriter(arg0 tally.Scope) (writer.Writer, error)

NewWriter mocks base method

type MockHandlerMockRecorder

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

MockHandlerMockRecorder is the mock recorder for MockHandler

func (*MockHandlerMockRecorder) Close

func (mr *MockHandlerMockRecorder) Close() *gomock.Call

Close indicates an expected call of Close

func (*MockHandlerMockRecorder) NewWriter

func (mr *MockHandlerMockRecorder) NewWriter(arg0 interface{}) *gomock.Call

NewWriter indicates an expected call of NewWriter

type Type

type Type string

Type is the handler type.

func (*Type) UnmarshalYAML

func (t *Type) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML unmarshals YAML into a type.

Directories

Path Synopsis
Package writer is a generated GoMock package.
Package writer is a generated GoMock package.

Jump to

Keyboard shortcuts

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