eventlog

package
v0.0.0-...-a733917 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultBufferSize = 5000

DefaultBufferSize is the number of unwritten state Events which may be held in queue before blocking.

Variables

View Source
var DefaultNewEventWriter = func(dest string, nodeID t.NodeID, logger logging.Logger) (EventWriter, error) {
	return NewGzipWriter(dest, gzip.BestSpeed, nodeID, logger)
}

DefaultNewEventWriter returns the default event writer. It returns the Gzip writer, making it the default event writer. In empirical tests comparing compression levels, best speed was only a few tenths of a percent worse than best compression, but your results may vary.

Functions

func EventLimitLogger

func EventLimitLogger(eventLimit int64) func(EventRecord) []EventRecord

EventLimitLogger returns a function for the interceptor that splits the logging file every eventLimit number of events

func EventNewEpochLogger

func EventNewEpochLogger(appModuleID stdtypes.ModuleID) func(record EventRecord) []EventRecord

Returns a file that splits an record slice into multiple slices every time a an event eventpb.Event_NewLogFile is found

func EventTrackerLogger

func EventTrackerLogger(newFile func(event stdtypes.Event) bool) func(time EventRecord) []EventRecord

eventTrackerLogger returns a function that tracks every single event of EventRecord and creates a new file for every event such that newFile(event) = True

func OneFileLogger

func OneFileLogger() func(EventRecord) []EventRecord

Types

type EventRecord

type EventRecord struct {
	Events *stdtypes.EventList
	Time   int64
}

func (*EventRecord) Filter

func (record *EventRecord) Filter(predicate func(event stdtypes.Event) bool) EventRecord

type EventWriter

type EventWriter interface {
	Write(record EventRecord) error
	Flush() error
	Close() error
}

func NewGzipWriter

func NewGzipWriter(filename string, compressionLevel int, nodeID stdtypes.NodeID, logger logging.Logger) (EventWriter, error)

func NewSqliteWriter

func NewSqliteWriter(filename string, nodeID t.NodeID, logger logging.Logger) (EventWriter, error)

type Interceptor

type Interceptor interface {

	// Intercept is called by the node each Time Events are passed to a module.
	// ATTENTION: Since this is an interface type, it can happen that a nil value of a concrete type is used in the node
	// and, consequently, Intercept(events) will be called on nil.
	// The implementation of the concrete type must make sure that calling Intercept even on the nil value
	// does not cause any problems.
	// For more explanation, see https://mangatmodi.medium.com/go-check-nil-interface-the-right-way-d142776edef1
	Intercept(events *stdtypes.EventList) error
}

Interceptor provides a way to gain insight into the internal operation of the node. Before being passed to the respective target modules, Events can be intercepted and logged for later analysis or replaying. An interceptor can be used for other purposes to, e.g., to gather statistical information or provide live monitoring.

func MultiInterceptor

func MultiInterceptor(interceptors ...Interceptor) Interceptor

type Reader

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

func NewReader

func NewReader(source io.Reader) (*Reader, error)

func (*Reader) ReadAllEvents

func (r *Reader) ReadAllEvents() ([]*eventpb.Event, error)

func (*Reader) ReadEntry

func (r *Reader) ReadEntry() (*recordingpb.Entry, error)

type Recorder

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

Recorder is intended to be used as an implementation of the mir.EventInterceptor interface. It receives state Events, serializes them, compresses them, and writes them to a stream.

func NewRecorder

func NewRecorder(
	nodeID stdtypes.NodeID,
	path string,
	logger logging.Logger,
	opts ...RecorderOpt,
) (*Recorder, error)

func (*Recorder) Intercept

func (i *Recorder) Intercept(events *stdtypes.EventList) error

Intercept takes an event and enqueues it into the event buffer. If there is no room in the buffer, it blocks. If draining the buffer to the output stream has completed (successfully or otherwise), Intercept returns an error.

func (*Recorder) Stop

func (i *Recorder) Stop() error

Stop must be invoked to release the resources associated with this Interceptor, and should only be invoked after the mir node has completely exited. The returned error

type RecorderOpt

type RecorderOpt interface{}

func BufferSizeOpt

func BufferSizeOpt(size int) RecorderOpt

BufferSizeOpt overrides the default buffer size of the interceptor buffer. Once the buffer overflows, the state machine will be blocked from receiving new state Events until the buffer has room.

func EventFilterOpt

func EventFilterOpt(filter func(event stdtypes.Event) bool) RecorderOpt

func EventWriterOpt

func EventWriterOpt(
	factory func(dest string, nodeID stdtypes.NodeID, logger logging.Logger) (EventWriter, error),
) RecorderOpt

func FileSplitterOpt

func FileSplitterOpt(splitter func(EventRecord) []EventRecord) RecorderOpt

func SyncWriteOpt

func SyncWriteOpt() RecorderOpt

func TimeSourceOpt

func TimeSourceOpt(source func() int64) RecorderOpt

TimeSourceOpt can be used to override the default Time source for an interceptor. This can be useful for changing the granularity of the timestamps, or picking some externally supplied sync point when trying to synchronize logs. The default Time source will timestamp with the Time, in milliseconds since the interceptor was created.

Jump to

Keyboard shortcuts

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