Documentation ¶
Index ¶
- Constants
- Variables
- func EventLimitLogger(eventLimit int64) func(EventRecord) []EventRecord
- func EventNewEpochLogger() func(record EventRecord) []EventRecord
- func EventTrackerLogger(newFile func(event *eventpb.Event) bool) func(time EventRecord) []EventRecord
- func OneFileLogger() func(EventRecord) []EventRecord
- type EventRecord
- type EventWriter
- type Interceptor
- type Reader
- type Recorder
- type 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 ¶ 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() 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
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 Close() error }
func NewGzipWriter ¶ added in v0.2.0
func NewSqliteWriter ¶ added in v0.2.0
type Interceptor ¶
type Interceptor interface { // Intercept is called each Time Events are passed to a module, if an Interceptor is present in the node. // The expected behavior of Intercept is to add the intercepted Events to a log for later analysis. // TODO: In the comment, also refer to the way Events can be analyzed or replayed. 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.
func MultiInterceptor ¶ added in v0.2.0
func MultiInterceptor(interceptors ...Interceptor) Interceptor
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
func (*Reader) ReadAllEvents ¶ added in v0.1.1
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 ¶ 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 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.