framer

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: MPL-2.0 Imports: 4 Imported by: 42

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// HeartbeatStreamFrame is the StreamFrame to send as a heartbeat, avoiding
	// creating many instances of the empty StreamFrame
	HeartbeatStreamFrame = &StreamFrame{}
)

Functions

This section is empty.

Types

type StreamFrame

type StreamFrame struct {
	// Offset is the offset the data was read from
	Offset int64 `json:",omitempty"`

	// Data is the read data
	Data []byte `json:",omitempty"`

	// File is the file that the data was read from
	File string `json:",omitempty"`

	// FileEvent is the last file event that occurred that could cause the
	// streams position to change or end
	FileEvent string `json:",omitempty"`
}

StreamFrame is used to frame data of a file when streaming

func (*StreamFrame) Clear

func (s *StreamFrame) Clear()

func (*StreamFrame) Copy added in v0.8.4

func (s *StreamFrame) Copy() *StreamFrame

func (*StreamFrame) IsCleared

func (s *StreamFrame) IsCleared() bool

func (*StreamFrame) IsHeartbeat

func (s *StreamFrame) IsHeartbeat() bool

IsHeartbeat returns if the frame is a heartbeat frame

type StreamFramer

type StreamFramer struct {
	// contains filtered or unexported fields
}

StreamFramer is used to buffer and send frames as well as heartbeat.

func NewStreamFramer

func NewStreamFramer(out chan<- *StreamFrame,
	heartbeatRate, batchWindow time.Duration, frameSize int) *StreamFramer

NewStreamFramer creates a new stream framer that will output StreamFrames to the passed output channel.

func (*StreamFramer) Destroy

func (s *StreamFramer) Destroy()

Destroy is used to cleanup the StreamFramer and flush any pending frames

func (*StreamFramer) ExitCh

func (s *StreamFramer) ExitCh() <-chan struct{}

ExitCh returns a channel that will be closed when the run loop terminates.

func (*StreamFramer) Run

func (s *StreamFramer) Run()

Run starts a long lived goroutine that handles sending data as well as heartbeating

func (*StreamFramer) Send

func (s *StreamFramer) Send(file, fileEvent string, data []byte, offset int64) error

Send creates and sends a StreamFrame based on the passed parameters. An error is returned if the run routine hasn't run or encountered an error. Send is asynchronous and does not block for the data to be transferred.

Jump to

Keyboard shortcuts

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