model

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const FrameHeaderLength = 128

FrameHeaderLength total header length size for each frame

Variables

This section is empty.

Functions

func CheckVersion

func CheckVersion(header *FrameHeader) bool

CheckVersion verifies that the binary format is compatible with the current release

func NewMultiReader

func NewMultiReader(r []io.Reader) <-chan Frame

NewFrameReader returns a channel of Frames. The channel is closed whenever there are no other frames or the FrameReader encounter an error reading a frame

func WriteFrame

func WriteFrame(w io.Writer, frame *Frame) error

WriteFrame writes the frame with the given uri to the WriteSeeker

Types

type ByNumber

type ByNumber []string

ByNumber helper struct to sort by last number all the log files

func (ByNumber) Len

func (s ByNumber) Len() int

func (ByNumber) Less

func (s ByNumber) Less(i, j int) bool

func (ByNumber) Swap

func (s ByNumber) Swap(i, j int)

type Collection

type Collection struct {
	Data []*Frame
}

Collection represents the file that contains all the subsequent frames

func ReadAll

func ReadAll(r io.Reader) *Collection

ReadAll reads all the Collection (Header, Frame*) and returns in a compound structure. NOTE: the NewFrameReader streaming implementation should be preferred

type Frame

type Frame struct {
	Header *FrameHeader
	Data   []byte
}

Frame represents one of the frame of the Collection file. It contains:

  • the Data slice that contains the data of the frame

func NewEmptyFrame

func NewEmptyFrame() *Frame

NewEmptyFrame generates a new empty frame

func NewFrame

func NewFrame(name string, uri string, data []byte) *Frame

NewFrame generates a new Frame from a given byte data

func ReadFrame

func ReadFrame(r io.Reader) (frame *Frame, err error)

ReadFrame reads the next frame from the Reader or returns an error in case it cannot interpret the Frame

func (*Frame) NameString

func (frame *Frame) NameString() string

Header.URIString converts the backing URI to a string

func (*Frame) URIString

func (frame *Frame) URIString() string

Header.URIString converts the backing URI to a string

type FrameHeader

type FrameHeader struct {
	Magic     [3]byte
	Version   [3]byte
	Reserved  [2]byte
	Size      int64
	Timestamp int64
	Name      [52]byte
	URI       [52]byte
}

FrameHeader represents the header of each Frame

  • a Size that represents how big is the the Data section
  • a Timestamp that represents when the Frame is snapshotted
  • a Name that represents the service that has been snapshotted
  • an URL that represents the service location

func ReadFrameHeader

func ReadFrameHeader(r io.Reader) (*FrameHeader, error)

ReadFrameHeader reads the next FrameHeader from the reader

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL