writer

package
v44.23.4 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const EVENT_BUFFER_SIZE = 200
View Source
const READ_BUFFER_SIZE = 4 * 1024 // XXX: 4kb chosen at random

Variables

View Source
var TempDir = ""

by default, use the system temp dir; this is overridden in tests so they can reliably clean up.

Functions

This section is empty.

Types

type Event

type Event struct {
	Number int
	Err    error
	Bytes  []byte
	Length int64
	End    bool
	Offset int64
}

type Handles

type Handles map[*StreamHandle]struct{}

Handles represents a set of *StreamHandles

type Stream

type Stream struct {
	Path string
	// contains filtered or unexported fields
}

func NewStream

func NewStream(read io.Reader) (*Stream, error)

func (*Stream) Consume

func (self *Stream) Consume() error

func (*Stream) GetState

func (self *Stream) GetState() (offset int64, ended bool)

Get the state of this stream in a thread-safe fashion

func (*Stream) Observe

func (self *Stream) Observe(start, stop int64) *StreamHandle

func (*Stream) Unobserve

func (self *Stream) Unobserve(handle *StreamHandle)

type StreamHandle

type StreamHandle struct {
	Start int64
	Stop  int64

	// Current offset in StreamHandle.
	Offset int64
	// contains filtered or unexported fields
}

func (*StreamHandle) WriteTo

func (self *StreamHandle) WriteTo(target io.Writer) (n int64, err error)

The WriteTo method is ideal for handling the special use cases here initially we want to optimize for reuse of buffers across reads/writes in the future we can also extend this mechanism for reading from disk if events "fall behind"

Jump to

Keyboard shortcuts

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