Documentation
¶
Index ¶
- Constants
- Variables
- func EventLimitLogger(eventLimit int64) func(EventRecord) []EventRecord
- func EventNewEpochLogger(appModuleID stdtypes.ModuleID) func(record EventRecord) []EventRecord
- func EventTrackerLogger(newFile func(event stdtypes.Event) bool) func(time EventRecord) []EventRecord
- func OneFileLogger() func(EventRecord) []EventRecord
- type EventRecord
- type EventWriter
- type Interceptor
- type Reader
- type Recorder
- type RecorderOpt
- func BufferSizeOpt(size int) RecorderOpt
- func EventFilterOpt(filter func(event stdtypes.Event) bool) RecorderOpt
- func EventWriterOpt(...) RecorderOpt
- func FileSplitterOpt(splitter func(EventRecord) []EventRecord) RecorderOpt
- func SyncWriteOpt() RecorderOpt
- func TimeSourceOpt(source func() int64) RecorderOpt
Constants ¶
const DefaultBufferSize = 5000
DefaultBufferSize is the number of unwritten state Events which may be held in queue before blocking.
Variables ¶
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 ¶
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 NewSqliteWriter ¶
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 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 ¶
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.