eventlog

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 23 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 added in v0.2.0

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 added in v0.2.0

func EventNewEpochLogger(appModuleID t.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 added in v0.2.0

func EventTrackerLogger(newFile func(event *eventpb.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 added in v0.2.0

func OneFileLogger() func(EventRecord) []EventRecord

Types

type EventRecord added in v0.2.0

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

func (*EventRecord) Filter added in v0.2.0

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

type EventWriter added in v0.2.0

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

func NewGzipWriter added in v0.2.0

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

func NewSqliteWriter added in v0.2.0

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 *events.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 added in v0.2.0

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 added in v0.1.1

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 t.NodeID,
	path string,
	logger logging.Logger,
	opts ...RecorderOpt,
) (*Recorder, error)

func (*Recorder) Intercept

func (i *Recorder) Intercept(events *events.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 added in v0.2.0

func EventFilterOpt(filter func(event *eventpb.Event) bool) RecorderOpt

func EventWriterOpt added in v0.2.0

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

func FileSplitterOpt added in v0.2.0

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

func SyncWriteOpt added in v0.4.1

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