header

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2023 License: Apache-2.0 Imports: 7 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeHeader

func DecodeHeader(bytes []byte, h *BytesHeader) (err error)

func EncodeHeader

func EncodeHeader(buf buffer.IoBuffer, h *BytesHeader)

func GetHeaderEncodeLength

func GetHeaderEncodeLength(h *BytesHeader) (size int)

Types

type BytesHeader

type BytesHeader struct {
	Kvs []BytesKV

	Changed bool
}

BytesHeader consists of multi key-value pair in byte slice formation. This could reduce the cost of []byte to string for protocol codec.

func (*BytesHeader) Add

func (h *BytesHeader) Add(Key string, Value string)

func (*BytesHeader) ByteSize

func (h *BytesHeader) ByteSize() (size uint64)

func (*BytesHeader) Clone

func (h *BytesHeader) Clone() *BytesHeader

func (*BytesHeader) Del

func (h *BytesHeader) Del(Key string)

func (*BytesHeader) Get

func (h *BytesHeader) Get(Key string) (Value string, ok bool)

~ BytesHeaderMap

func (*BytesHeader) Range

func (h *BytesHeader) Range(f func(Key, Value string) bool)

func (*BytesHeader) Set

func (h *BytesHeader) Set(Key string, Value string)

type BytesKV

type BytesKV struct {
	Key   []byte
	Value []byte
}

BytesKV key-value pair in byte slice

type CommonHeader

type CommonHeader map[string]string

CommonHeader wrapper for map[string]string, is an implementation of api.HeaderMap

func (CommonHeader) Add

func (h CommonHeader) Add(key string, value string)

Add value for given key. Multiple headers with the same key may be added with this function. Use Set for setting a single header for the given key.

func (CommonHeader) ByteSize

func (h CommonHeader) ByteSize() uint64

func (CommonHeader) Clone

func (h CommonHeader) Clone() api.HeaderMap

Clone used to deep copy header's map

func (CommonHeader) Del

func (h CommonHeader) Del(key string)

Del delete pair of specified key

func (CommonHeader) Get

func (h CommonHeader) Get(key string) (value string, ok bool)

Get value of key

func (CommonHeader) Range

func (h CommonHeader) Range(f func(key, value string) bool)

Range calls f sequentially for each key and value present in the map. If f returns false, range stops the iteration.

func (CommonHeader) Set

func (h CommonHeader) Set(key string, value string)

Set key-value pair in header map, the previous pair will be replaced if exists

Jump to

Keyboard shortcuts

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