admission

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

package admission is a fast way to ingest/send metrics.

Index

Constants

View Source
const (
	// DefaultMessages is the number of Messages passed to a ReadBatch call
	// in the Dispatcher Run loop.
	DefaultMessages = 16

	// DefaultInFlight is the number of concurrent calls to the Handler
	// allowed in the Run loop. If it would go over, the message is dropped.
	DefaultInFlight = 256
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher struct {
	// Handler is an interface called with each read Message.
	Handler Handler

	// Conn is the connection the packets are read from.
	Conn syscall.RawConn

	// NumMessages is the number of messages to attempt to read at once. If
	// zero, DefaultMessages is used.
	NumMessages int

	// InFlight controls the number of parallel calls to the Handler. Zero is
	// DefaultInFlight.
	InFlight int

	// Hooks provide callbacks for events in the dispatcher.
	Hooks struct {
		// when messages were read with how many.
		ReadMessages func(ctx context.Context, n int)
		// when a message is dropped.
		DroppedMessage func(ctx context.Context)
	}
}

Dispatcher reads Messages on the PacketConn and forwards them into the Handler in parallel.

func (Dispatcher) Run

func (d Dispatcher) Run(ctx context.Context) (err error)

Run reads messages and passes them to the handler in their own goroutines until the context is cancelled.

type Handler

type Handler interface {
	// Handle should do things with the message Data. No fields of the message
	// should be held on to after the call has returned.
	Handle(ctx context.Context, m *Message)
}

Handler is a type that can handle messages.

type Message

type Message = batch.Message

Message is what is handled by a handler.

Directories

Path Synopsis
package admmonkit hooks up admission with monkit.v2
package admmonkit hooks up admission with monkit.v2
package admproto describes the admission protocol
package admproto describes the admission protocol
internal

Jump to

Keyboard shortcuts

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