github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/trace/v2/reader.go (about)

     1  // Copyright 2023 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package trace
     6  
     7  import (
     8  	"github.com/shogo82148/std/bufio"
     9  	"github.com/shogo82148/std/io"
    10  )
    11  
    12  // Reader reads a byte stream, validates it, and produces trace events.
    13  type Reader struct {
    14  	r           *bufio.Reader
    15  	lastTs      Time
    16  	gen         *generation
    17  	spill       *spilledBatch
    18  	frontier    []*batchCursor
    19  	cpuSamples  []cpuSample
    20  	order       ordering
    21  	emittedSync bool
    22  
    23  	go121Events *oldTraceConverter
    24  }
    25  
    26  // NewReader creates a new trace reader.
    27  func NewReader(r io.Reader) (*Reader, error)
    28  
    29  // ReadEvent reads a single event from the stream.
    30  //
    31  // If the stream has been exhausted, it returns an invalid
    32  // event and io.EOF.
    33  func (r *Reader) ReadEvent() (e Event, err error)