sink

package
v1.10.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2021 License: Apache-2.0 Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dispatch

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

Dispatch implements consumer.MonitorConsumer and dispatches incoming recorder captures to registered sinks based on their rule ID.

func NewDispatch

func NewDispatch(sinkQueueSize int) (*Dispatch, error)

NewDispatch creates a new sink dispatcher. Each registered sink may have a queue of up to sinkQueueSize pending captures.

func (*Dispatch) NotifyAgentEvent

func (d *Dispatch) NotifyAgentEvent(typ int, message interface{})

NotifyAgentEvent implements consumer.MonitorConsumer

func (*Dispatch) NotifyPerfEvent

func (d *Dispatch) NotifyPerfEvent(data []byte, cpu int)

NotifyPerfEvent implements consumer.MonitorConsumer

func (*Dispatch) NotifyPerfEventLost

func (d *Dispatch) NotifyPerfEventLost(numLostEvents uint64, cpu int)

NotifyPerfEventLost implements consumer.MonitorConsumer

func (*Dispatch) RegisterSink added in v1.10.0

func (d *Dispatch) RegisterSink(ctx context.Context, ruleID uint16, w pcap.RecordWriter, header pcap.Header) (*Handle, error)

RegisterSink registers a new sink for the given rule ID. Any captures with a matching rule ID will be forwarded to the pcap sink w. The provided header is written to the pcap sink w upon initialization.

func (*Dispatch) UnregisterSink added in v1.10.0

func (d *Dispatch) UnregisterSink(ctx context.Context, ruleID uint16) (stats Statistics, err error)

UnregisterSink will stop and unregister the sink for the given ruleID. It waits for any pending packets to be forwarded to the sink before closing it and returns the final statistics or an error, if an error occurred.

type Handle

type Handle struct {
	// C is a channel on which receives a new empty message whenever there
	// was an update to the sink statistics. It is closed when the sink stops
	// updating.
	C <-chan struct{}
	// contains filtered or unexported fields
}

Handle enables the owner to subscribe to sink statistics

func (*Handle) Stats

func (h *Handle) Stats() Statistics

type Statistics

type Statistics struct {
	PacketsWritten uint64
	BytesWritten   uint64
	PacketsLost    uint64
	BytesLost      uint64
}

Statistics contains the statistics for a pcap sink

Jump to

Keyboard shortcuts

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