blockwise

package
v3.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 21 Imported by: 8 modules, 7 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// SZX16 block of size 16bytes
	SZX16 = blocks.SZX16
	// SZX32 block of size 32bytes
	SZX32 = blocks.SZX32
	// SZX64 block of size 64bytes
	SZX64 = blocks.SZX64
	// SZX128 block of size 128bytes
	SZX128 = blocks.SZX128
	// SZX256 block of size 256bytes
	SZX256 = blocks.SZX256
	// SZX512 block of size 512bytes
	SZX512 = blocks.SZX512
	// SZX1024 block of size 1024bytes
	SZX1024 = blocks.SZX1024
	// SZXBERT block of size n*1024bytes
	SZXBERT = blocks.SZXBERT
)
View Source
const (
	QBlockwiseDisabled = qblock.QBlockwiseDisabled
	QBlockwiseAuto     = qblock.QBlockwiseAuto
	QBlockwiseOnly     = qblock.QBlockwiseOnly
)
View Source
const (
	DefaultReceivingMessagesCacheMaxEntries = 4096
)

Variables

View Source
var (
	// ErrBlockNumberExceedLimit block number exceeded the limit 1,048,576
	ErrBlockNumberExceedLimit = blocks.ErrBlockNumberExceedLimit

	// ErrBlockInvalidSize block has invalid size
	ErrBlockInvalidSize = blocks.ErrBlockInvalidSize

	// ErrInvalidOptionBlock2 message has invalid value of Block2
	ErrInvalidOptionBlock2 = blocks.ErrInvalidOptionBlock2

	// ErrInvalidOptionBlock1 message has invalid value of Block1
	ErrInvalidOptionBlock1 = blocks.ErrInvalidOptionBlock1

	// ErrInvalidResponseCode response code has invalid value
	ErrInvalidResponseCode = errors.New("response code has invalid value")

	// ErrInvalidPayloadSize invalid payload size
	ErrInvalidPayloadSize = errors.New("invalid payload size")

	// ErrInvalidSZX invalid block-wise transfer szx
	ErrInvalidSZX = blocks.ErrInvalidSZX

	// ErrRequestEntityIncomplete request body is missing blocks
	ErrRequestEntityIncomplete = errors.New("request entity incomplete")

	// ErrRequestEntityTooLarge request body exceeds the size limit
	ErrRequestEntityTooLarge = blocks.ErrRequestEntityTooLarge
)
View Source
var (
	ErrInvalidMissingBlocks = qblock.ErrInvalidMissingBlocks
	ErrQBlockInvalidSize    = qblock.ErrQBlockInvalidSize
	ErrQBlockInvalidNUM     = qblock.ErrQBlockInvalidNUM
	ErrQBlockIncomplete     = qblock.ErrQBlockIncomplete
	ErrQBlockConflict       = qblock.ErrQBlockConflict
	ErrQBlockTooLarge       = qblock.ErrQBlockTooLarge
	ErrQBlockScheduleFull   = qblock.ErrQBlockScheduleFull
	ErrQBlockInvalidMode    = qblock.ErrQBlockInvalidMode
	ErrQBlockNeedsBlockwise = qblock.ErrQBlockNeedsBlockwise
	ErrQBlockDisabled       = qblock.ErrQBlockDisabled
	ErrQBlockUnsupported    = qblock.ErrQBlockUnsupported
)

Q-Block errors are shared with the dedicated qblock package.

Functions

func DecodeMissingBlocks added in v3.7.0

func DecodeMissingBlocks(dst []uint32, data []byte) ([]uint32, error)

DecodeMissingBlocks appends validated, deduplicated NUMs to dst.

func EncodeBlockOption

func EncodeBlockOption(szx SZX, blockNumber int64, moreBlocksFollowing bool) (uint32, error)

EncodeBlockOption encodes block values to coap option.

func EncodeMissingBlocks added in v3.7.0

func EncodeMissingBlocks(dst []byte, blocks []uint32) ([]byte, error)

EncodeMissingBlocks appends an RFC 9177 unsigned CBOR sequence to dst.

func EncodeQBlockOption added in v3.7.0

func EncodeQBlockOption(szx SZX, num int64, more bool) (uint32, error)

EncodeQBlockOption encodes a datagram Q-Block option.

func ValidateQBlockwiseConfig added in v3.7.0

func ValidateQBlockwiseConfig(mode QBlockwiseMode, blockwiseEnabled bool) error

ValidateQBlockwiseConfig checks Q mode and blockwise support.

Types

type BlockWise

type BlockWise[C Client] struct {
	// contains filtered or unexported fields
}

func New

func New[C Client](
	cc C,
	expiration time.Duration,
	errors func(error),
	getSentRequestFromOutside func(token message.Token) (*pool.Message, bool),
) *BlockWise[C]

New provides blockwise. getSentRequestFromOutside must returns a copy of request which will be released after use.

func (*BlockWise[C]) CancelQBlockObservation added in v3.7.0

func (b *BlockWise[C]) CancelQBlockObservation(token message.Token, remote net.Addr)

CancelQBlockObservation drops a Q registration and its partial outgoing body.

func (*BlockWise[C]) CheckExpirations

func (b *BlockWise[C]) CheckExpirations(now time.Time)

CheckExpirations iterates over caches and remove expired items.

func (*BlockWise[C]) CloseQBlockTransfers added in v3.7.0

func (b *BlockWise[C]) CloseQBlockTransfers()

CloseQBlockTransfers releases retained Q state when the connection closes.

func (*BlockWise[C]) Do

func (b *BlockWise[C]) Do(r *pool.Message, maxSzx SZX, maxMessageSize uint32, remoteAddr net.Addr, do func(req *pool.Message) (*pool.Message, error)) (*pool.Message, error)

Do sends an coap message and returns an coap response via blockwise transfer.

func (*BlockWise[C]) DoQBlock1 added in v3.7.0

func (b *BlockWise[C]) DoQBlock1(r *pool.Message, szx SZX, maxBodySize int64,
	do func(*pool.Message) (*pool.Message, error),
) (*pool.Message, error)

DoQBlock1 sends a request body using Q-Block1.

func (*BlockWise[C]) DoQBlock2 added in v3.7.0

func (b *BlockWise[C]) DoQBlock2(req *pool.Message, szx SZX,
	do func(*pool.Message) (*pool.Message, error),
) (*pool.Message, error)

DoQBlock2 requests and assembles a Q-Block2 body.

func (*BlockWise[C]) Handle

func (b *BlockWise[C]) Handle(w *responsewriter.ResponseWriter[C], r *pool.Message, maxSZX SZX, maxMessageSize uint32, remoteAddr net.Addr, next func(w *responsewriter.ResponseWriter[C], r *pool.Message))

Handle middleware which constructs COAP request from blockwise transfer and send COAP response via blockwise.

func (*BlockWise[C]) ReceiveQBlock2 added in v3.7.0

func (b *BlockWise[C]) ReceiveQBlock2(req *pool.Message, szx SZX, exchange QBlockExchange, initial *pool.Message) (*pool.Message, error)

ReceiveQBlock2 assembles a response body from an existing transfer route.

func (*BlockWise[C]) SetMaxReceiveBodySize added in v3.5.6

func (b *BlockWise[C]) SetMaxReceiveBodySize(size int64)

SetMaxReceiveBodySize limits the Block1 body size, 0 means unlimited.

func (*BlockWise[C]) SetQBlockwiseConfig added in v3.7.0

func (b *BlockWise[C]) SetQBlockwiseConfig(config QBlockwiseConfig) error

SetQBlockwiseConfig sets Q parameters before the first transfer.

func (*BlockWise[C]) SetReceivingMessagesCacheMaxEntries added in v3.5.7

func (b *BlockWise[C]) SetReceivingMessagesCacheMaxEntries(maxEntries int)

SetReceivingMessagesCacheMaxEntries sets max entries for in-flight incoming block-wise assemblies per connection, including concurrent transfers. Value 0 means unlimited.

func (*BlockWise[C]) SetRollingExpiration added in v3.5.6

func (b *BlockWise[C]) SetRollingExpiration(enabled bool)

SetRollingExpiration resets the Block1 transfer expiration on each new block.

func (*BlockWise[C]) WriteMessage

func (b *BlockWise[C]) WriteMessage(request *pool.Message, maxSZX SZX, maxMessageSize uint32, remoteAddr net.Addr, writeMessage func(r *pool.Message) error) error

WriteMessage sends an coap message via blockwise transfer.

type Client

type Client interface {
	// create message from pool
	AcquireMessage(ctx context.Context) *pool.Message
	// return back the message to the pool for next use
	ReleaseMessage(m *pool.Message)
}

type QBlockAssembly added in v3.7.0

type QBlockAssembly = qblock.Assembly

QBlockAssembly is a bounded sparse Q-Block body receiver.

func NewQBlockAssembly added in v3.7.0

func NewQBlockAssembly(szx SZX, bodySize, maxBodySize int64, maxBlocks int) (*QBlockAssembly, error)

NewQBlockAssembly creates a sparse receiver with explicit resource bounds.

type QBlockExchange added in v3.7.0

type QBlockExchange = qblock.Exchange

QBlockExchange routes body responses until it is closed.

type QBlockSender added in v3.7.0

type QBlockSender = qblock.Sender

QBlockSender reads replayable Q-Block payloads.

func NewQBlockSender added in v3.7.0

func NewQBlockSender(body io.ReadSeeker, szx SZX, bodySize int64) (*QBlockSender, error)

NewQBlockSender creates a replayable body sender.

type QBlockTransport added in v3.7.0

type QBlockTransport = qblock.Transport

QBlockTransport provides datagram sending, routing, and scheduling.

type QBlockwiseConfig added in v3.7.0

type QBlockwiseConfig = qblock.Config

QBlockwiseConfig configures RFC 9177 congestion and recovery parameters.

type QBlockwiseMode added in v3.7.0

type QBlockwiseMode = qblock.QBlockwiseMode

QBlockwiseMode selects RFC 9177 use for datagram transfers.

type SZX

type SZX = blocks.SZX

SZX enum representation for the size of the block: https://tools.ietf.org/html/rfc7959#section-2.2

func DecodeBlockOption

func DecodeBlockOption(blockVal uint32) (szx SZX, blockNumber int64, moreBlocksFollowing bool, err error)

DecodeBlockOption decodes coap block option to block values.

func DecodeQBlockOption added in v3.7.0

func DecodeQBlockOption(value uint32) (szx SZX, num int64, more bool, err error)

DecodeQBlockOption decodes a datagram Q-Block option.

Directories

Path Synopsis
internal
blocks
Package blocks contains wire types shared by the legacy and Q-Block engines.
Package blocks contains wire types shared by the legacy and Q-Block engines.
Package qblock implements RFC 9177 datagram transfers independently of the legacy RFC 7959 blockwise engine.
Package qblock implements RFC 9177 datagram transfers independently of the legacy RFC 7959 blockwise engine.

Jump to

Keyboard shortcuts

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