consumers

package
v0.9.1-0...-9c46226 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package consumers contains consumers that can be readily used by other packages without having to implement the EventConsumerHandler interface manually: - ProcessConsumer (process.go): a consumer of process exec/exit events that can be subscribed to via callbacks

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProcessCallback

type ProcessCallback = func(uint32)

ProcessCallback is a callback function that will be called when a process exec/exit event is received Defined as an alias to avoid type incompatibilities

type ProcessConsumer

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

ProcessConsumer represents a consumer of process exec/exit events that can be subscribed to via callbacks

func NewProcessConsumer

func NewProcessConsumer(id string, chanSize int, eventTypes []ProcessConsumerEventTypes, evm *eventmonitor.EventMonitor) (*ProcessConsumer, error)

NewProcessConsumer creates a new ProcessConsumer, registering itself with the given event monitor. This function should be called with the EventMonitor instance created in cmd/system-probe/modules/eventmonitor.go:createEventMonitorModule. For tests, use consumers/testutil.NewTestProcessConsumer, which also initializes the event stream for testing accordingly

func (*ProcessConsumer) ChanSize

func (p *ProcessConsumer) ChanSize() int

ChanSize returns the size of the channel that the event monitor will use to send events to this handler

func (*ProcessConsumer) Copy

func (p *ProcessConsumer) Copy(ev *model.Event) any

Copy copies the event from the eventmonitor type to the one we use in this struct

func (*ProcessConsumer) EventTypes

func (p *ProcessConsumer) EventTypes() []model.EventType

EventTypes returns the event types that this handler is interested in

func (*ProcessConsumer) HandleEvent

func (p *ProcessConsumer) HandleEvent(ev any)

HandleEvent handles the event from the event monitor

func (*ProcessConsumer) ID

func (p *ProcessConsumer) ID() string

ID returns the ID of the consumer

func (*ProcessConsumer) Start

func (p *ProcessConsumer) Start() error

Start starts the consumer, this is a no-op for this implementation

func (*ProcessConsumer) Stop

func (p *ProcessConsumer) Stop()

Stop stops the consumer, this is a no-op for this implementation

func (*ProcessConsumer) SubscribeExec

func (p *ProcessConsumer) SubscribeExec(callback ProcessCallback) func()

SubscribeExec subscribes to process exec events, and returns the function that needs to be called to unsubscribe

func (*ProcessConsumer) SubscribeExit

func (p *ProcessConsumer) SubscribeExit(callback ProcessCallback) func()

SubscribeExit subscribes to process exit events, and returns the function that needs to be called to unsubscribe

func (*ProcessConsumer) SubscribeFork

func (p *ProcessConsumer) SubscribeFork(callback ProcessCallback) func()

SubscribeFork subscribes to process fork events, and returns the function that needs to be called to unsubscribe. Important: these callbacks will only be called if the ProcessConsumer was created with the ListenToForkEvents option set to true

type ProcessConsumerEventTypes

type ProcessConsumerEventTypes model.EventType

ProcessConsumerEventTypes represents the types of events that the ProcessConsumer can handle, a subset of the model.EventType

const (
	// ExecEventType represents process open events
	ExecEventType ProcessConsumerEventTypes = ProcessConsumerEventTypes(model.ExecEventType)

	// ExitEventType represents process exit events
	ExitEventType ProcessConsumerEventTypes = ProcessConsumerEventTypes(model.ExitEventType)

	// ForkEventType represents process fork events
	ForkEventType ProcessConsumerEventTypes = ProcessConsumerEventTypes(model.ForkEventType)
)

Jump to

Keyboard shortcuts

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