Package history implements serialization and deserilization of historical records used for RTS evaluation.

RTS evaluation uses history files to emulate CQ behavior with a candidate selection strategy. Conceptually a history file is a sequence of Record protobuf messages, see More specifically, it is a Zstd-compressed RecordIO-encoded sequence of Records.

TODO(nodir): delete this package in favor of .jsonl.gz files.



This section is empty.


This section is empty.


This section is empty.


type Player

type Player struct {
	RejectionC chan *evalpb.Rejection
	DurationC  chan *evalpb.TestDuration
	// contains filtered or unexported fields

Player can playback a history from a reader. It takes care of reconstructing rejections from fragments.

func NewPlayer

func NewPlayer(r *Reader) *Player

NewPlayer returns a new Player.

func (*Player) Playback

func (p *Player) Playback(ctx context.Context) error

Playback reads historical records and dispatches them to p.RejectionC and p.DurationC. Before exiting, closes RejectionC, DurationC and the underlying reader.

TODO(nodir): refactor this package and potentially the file format. This function is never used.

func (*Player) PlaybackDurations

func (p *Player) PlaybackDurations(ctx context.Context) error

PlaybackDurations is like Playback, except reports only durations.

func (*Player) PlaybackRejections

func (p *Player) PlaybackRejections(ctx context.Context) error

PlaybackRejections is like Playback, except reports only rejections.

type Reader

type Reader struct {
	// contains filtered or unexported fields

Reader deserializes historical records from an io.Reader.

func NewReader

func NewReader(r io.Reader) *Reader

NewReader creates a Reader.

func OpenFile

func OpenFile(path string) (*Reader, error)

OpenFile creates a Reader that reads data from a file. When done, call Close() on the returned Reader.

func (*Reader) Close

func (r *Reader) Close() error

Close releases all resources and closes the underlying io.Reader.

func (*Reader) Read

func (r *Reader) Read() (*evalpb.Record, error)

Read reads the next historical record. Returns io.EOF if there is no record.

type Writer

type Writer struct {
	// contains filtered or unexported fields

Writer serializes historical records to an io.Writer.

func CreateFile

func CreateFile(path string) (*Writer, error)

CreateFile returns Writer that persists data to a new file. When done, call Close() on the returned Writer.

func NewWriter

func NewWriter(w io.Writer) *Writer

NewWriter creates a Writer.

func (*Writer) Close

func (w *Writer) Close() error

Close flushes everything and closes the underlying io.Writer.

func (*Writer) Write

func (w *Writer) Write(rec *evalpb.Record) error

Write writes a historical record.