pool

package
v3.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: Apache-2.0 Imports: 11 Imported by: 39

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

type Decoder interface {
	Decode(buf []byte, m *message.Message) (int, error)
}

type Encoder

type Encoder interface {
	Size(m message.Message) (int, error)
	Encode(m message.Message, buf []byte) (int, error)
}

type Message

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

func NewMessage

func NewMessage(ctx context.Context) *Message

func (*Message) Accept

func (r *Message) Accept() (message.MediaType, error)

Accept get's accept option.

func (*Message) AddETag

func (r *Message) AddETag(value []byte) error

AddETag appends value to existing ETags.

Option definition: - format: opaque, length: 1-8, repeatable

func (*Message) AddOptionBytes

func (r *Message) AddOptionBytes(opt message.OptionID, value []byte)

func (*Message) AddOptionString

func (r *Message) AddOptionString(opt message.OptionID, value string)

func (*Message) AddOptionUint32

func (r *Message) AddOptionUint32(opt message.OptionID, value uint32)

func (*Message) AddQuery

func (r *Message) AddQuery(query string)

func (*Message) Body

func (r *Message) Body() io.ReadSeeker

func (*Message) BodySize

func (r *Message) BodySize() (int64, error)

func (*Message) Clone added in v3.1.0

func (r *Message) Clone(msg *Message) error

func (*Message) Code

func (r *Message) Code() codes.Code

func (*Message) ContentFormat

func (r *Message) ContentFormat() (message.MediaType, error)

func (*Message) Context

func (r *Message) Context() context.Context

func (*Message) ControlMessage added in v3.2.0

func (r *Message) ControlMessage() *net.ControlMessage

func (*Message) ETag

func (r *Message) ETag() ([]byte, error)

ETag returns first ETag value

func (*Message) ETags

func (r *Message) ETags(b [][]byte) (int, error)

ETags returns all ETag values

Writes ETag values to output array, returns number of written values or error.

func (*Message) GetOptionAllBytes

func (r *Message) GetOptionAllBytes(id message.OptionID, b [][]byte) (int, error)

GetOptionAllBytes gets array of bytes of all options with given ID.

func (*Message) GetOptionBytes

func (r *Message) GetOptionBytes(id message.OptionID) ([]byte, error)

GetOptionBytes gets bytes of the first option with given ID.

func (*Message) GetOptionUint32

func (r *Message) GetOptionUint32(id message.OptionID) (uint32, error)

func (*Message) HasOption

func (r *Message) HasOption(id message.OptionID) bool

func (*Message) Hijack

func (r *Message) Hijack()

func (*Message) IsHijacked

func (r *Message) IsHijacked() bool

func (*Message) IsModified

func (r *Message) IsModified() bool

func (*Message) IsPing added in v3.3.0

func (r *Message) IsPing(isTCP bool) bool

func (*Message) IsSeparateMessage

func (r *Message) IsSeparateMessage() bool

func (*Message) MarshalWithEncoder

func (r *Message) MarshalWithEncoder(encoder Encoder) ([]byte, error)

func (*Message) MessageID

func (r *Message) MessageID() int32

MessageID returns 0 to 2^16-1 otherwise it contains invalid value.

func (*Message) MustSetPath

func (r *Message) MustSetPath(p string)

MustSetPath calls SetPath and panics if it returns an error.

func (*Message) Observe

func (r *Message) Observe() (uint32, error)

func (*Message) Options

func (r *Message) Options() message.Options

func (*Message) Path

func (r *Message) Path() (string, error)

func (*Message) Queries

func (r *Message) Queries() ([]string, error)

func (*Message) ReadBody

func (r *Message) ReadBody() ([]byte, error)

func (*Message) Remove

func (r *Message) Remove(opt message.OptionID)

func (*Message) Reset

func (r *Message) Reset()

Reset clear message for next reuse

func (*Message) ResetOptionsTo

func (r *Message) ResetOptionsTo(in message.Options)

func (*Message) Sequence

func (r *Message) Sequence() uint64

func (*Message) SetAccept

func (r *Message) SetAccept(contentFormat message.MediaType)

SetAccept set's accept option.

func (*Message) SetBody

func (r *Message) SetBody(s io.ReadSeeker)

func (*Message) SetCode

func (r *Message) SetCode(code codes.Code)

func (*Message) SetContentFormat

func (r *Message) SetContentFormat(contentFormat message.MediaType)

func (*Message) SetContext

func (r *Message) SetContext(ctx context.Context)

func (*Message) SetControlMessage added in v3.2.0

func (r *Message) SetControlMessage(cm *net.ControlMessage)

func (*Message) SetETag

func (r *Message) SetETag(value []byte) error

SetETag inserts/replaces ETag option(s).

After a successful call only a single ETag value will remain.

func (*Message) SetMessage

func (r *Message) SetMessage(message message.Message)

func (*Message) SetMessageID

func (r *Message) SetMessageID(mid int32)

SetMessageID only 0 to 2^16-1 are valid.

func (*Message) SetModified

func (r *Message) SetModified(b bool)

func (*Message) SetObserve

func (r *Message) SetObserve(observe uint32)

func (*Message) SetOptionBytes

func (r *Message) SetOptionBytes(opt message.OptionID, value []byte)

func (*Message) SetOptionString

func (r *Message) SetOptionString(opt message.OptionID, value string)

func (*Message) SetOptionUint32

func (r *Message) SetOptionUint32(opt message.OptionID, value uint32)

func (*Message) SetPath

func (r *Message) SetPath(p string) error

SetPath stores the given path within URI-Path options.

The value is stored by the algorithm described in RFC7252 and using the internal buffer. If the path is too long, but valid (URI-Path segments must have maximal length of 255) the internal buffer is expanded. If the path is too long, but not valid then the function returns ErrInvalidValueLength error.

func (*Message) SetSequence

func (r *Message) SetSequence(seq uint64)

func (*Message) SetToken

func (r *Message) SetToken(token message.Token)

func (*Message) SetType

func (r *Message) SetType(typ message.Type)

func (*Message) SetupDelete

func (r *Message) SetupDelete(path string, token message.Token, opts ...message.Option) error

func (*Message) SetupGet

func (r *Message) SetupGet(path string, token message.Token, opts ...message.Option) error

func (*Message) SetupPost

func (r *Message) SetupPost(path string, token message.Token, contentFormat message.MediaType, payload io.ReadSeeker, opts ...message.Option) error

func (*Message) SetupPut

func (r *Message) SetupPut(path string, token message.Token, contentFormat message.MediaType, payload io.ReadSeeker, opts ...message.Option) error

func (*Message) String

func (r *Message) String() string

func (*Message) Token

func (r *Message) Token() message.Token

func (*Message) Type

func (r *Message) Type() message.Type

func (*Message) UnmarshalWithDecoder

func (r *Message) UnmarshalWithDecoder(decoder Decoder, data []byte) (int, error)

func (*Message) UpsertControlMessage added in v3.2.0

func (r *Message) UpsertControlMessage(cm *net.ControlMessage)

UpsertControlMessage set value only when origin value is not set.

func (*Message) UpsertMessageID

func (r *Message) UpsertMessageID(mid int32)

UpsertMessageID set value only when origin value is invalid. Only 0 to 2^16-1 values are valid.

func (*Message) UpsertType

func (r *Message) UpsertType(typ message.Type)

UpsertType set value only when origin value is invalid. Only 0 to 2^8-1 values are valid.

type Pool

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

func New

func New(maxNumMessages uint32, maxMessageBufferSize uint16) *Pool

func (*Pool) AcquireMessage

func (p *Pool) AcquireMessage(ctx context.Context) *Message

AcquireMessage returns an empty Message instance from Message pool.

The returned Message instance may be passed to ReleaseMessage when it is no longer needed. This allows Message recycling, reduces GC pressure and usually improves performance.

func (*Pool) ReleaseMessage

func (p *Pool) ReleaseMessage(req *Message)

ReleaseMessage returns req acquired via AcquireMessage to Message pool.

It is forbidden accessing req and/or its' members after returning it to Message pool.

Jump to

Keyboard shortcuts

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