events

package
v0.0.0-...-dbadf91 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EventHandler

type EventHandler func(e *model.ProcessEvent)

EventHandler is a function used by the listener to handle a collected process event

type RingStore

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

RingStore implements the Store interface using a ring buffer The buffer is accessed by a single routine so it doesn't need to be protected by a mutex It holds two pointers, head and tail, to access the ring buffer head points to the oldest event in the buffer, where data should be consumed from tail points to the node where the next event will be inserted into head = tail if

  • the store is empty, in which case the underlying ringNode doesn't have any data
  • the store is full. Subsequent Push operations override the data pointed by head and move both head and tail to the next position

func (*RingStore) Pull

func (s *RingStore) Pull(_ context.Context, timeout time.Duration) ([]*model.ProcessEvent, error)

Pull returns all events stored in the RingStore

func (*RingStore) Push

func (s *RingStore) Push(e *model.ProcessEvent, done chan bool) error

Push adds an event to the RingStore. If the store is full, the oldest event is dropped to make space for the new one The done channel is optional. It's used to signal if the event has been successfully written to the Store

func (*RingStore) Run

func (s *RingStore) Run()

Run starts the RingStore. A go routine is created to serve push and pull requests in order to protect the underlying storage from concurrent access

func (*RingStore) Stop

func (s *RingStore) Stop()

Stop stops the RingStore's internal routine

type Store

type Store interface {
	// Run starts the store
	Run()
	// Stop stops the store
	Stop()
	// Push sends an event to be stored. An optional channel can be passed to acknowledge when the event is successfully written
	Push(*model.ProcessEvent, chan bool) error
	// Pull fetches all events in the store that haven't been consumed yet
	Pull(context.Context, time.Duration) ([]*model.ProcessEvent, error)
}

Store defines an interface to store process events in-memory

func NewRingStore

func NewRingStore(cfg pkgconfigmodel.Reader, client statsd.ClientInterface) (Store, error)

NewRingStore creates a new RingStore to store process events

type SysProbeListener

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

SysProbeListener collects process events using the event monitoring module in system-probe

func NewListener

func NewListener(handler EventHandler) (*SysProbeListener, error)

NewListener returns a new SysProbeListener to listen for process events

func NewSysProbeListener

func NewSysProbeListener(conn *grpc.ClientConn, client api.EventMonitoringModuleClient, handler EventHandler) (*SysProbeListener, error)

NewSysProbeListener returns a new SysPobeListener

func (*SysProbeListener) Run

func (l *SysProbeListener) Run()

Run starts a new thread to listen for process events

func (*SysProbeListener) Stop

func (l *SysProbeListener) Stop()

Stop stops the thread listening for process events

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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