fragmentation

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MinFragment is minimum fragment size in bytes.
	MinFragment = framing.HeaderLen + 4
	// MaxFragment is minimum fragment size in bytes.
	MaxFragment = common.MaxUint24 - 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HeaderAndPayload

type HeaderAndPayload interface {
	payload.Payload
	// Header returns a header of frame.
	Header() framing.FrameHeader
}

HeaderAndPayload is Payload which having a FrameHeader.

type Joiner

type Joiner interface {
	HeaderAndPayload
	// First returns the first frame.
	First() framing.Frame
	// Push append a new frame and returns true if joiner is end.
	Push(elem HeaderAndPayload) (end bool)
}

Joiner is used to join frames to a payload.

func NewJoiner

func NewJoiner(first HeaderAndPayload) Joiner

NewJoiner returns a new joiner.

type Splitter

type Splitter interface {
	// Split split data and metadata to frames.
	Split(placeholder int, data []byte, metadata []byte, onFrame func(idx int, fg framing.FrameFlag, body *common.ByteBuff)) error
	// ShouldSplit returns the answer with given payload size.
	ShouldSplit(size int) bool
}

Splitter is used to split payload data and metadata to frames.

func NewSplitter

func NewSplitter(fragment int) (splitter Splitter, err error)

NewSplitter returns a new splitter.

Jump to

Keyboard shortcuts

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