readwriter

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SeataV1PackageHeaderReservedLength = 16
)

*

  • <pre>
  • 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  • +-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+
  • | magic |Proto| Full length | Head | Msg |Seria|Compr| RequestID |
  • | code |colVer| (head+body) | Length |Type |lizer|ess | |
  • +-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
  • | |
  • | Head Map [Optional] |
  • +-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
  • | |
  • | body |
  • | |
  • | ... ... |
  • +-----------------------------------------------------------------------------------------------+
  • </pre>
  • <p>
  • <li>Full Length: include all data </li>
  • <li>Head Length: include head data from magic code to head map. </li>
  • <li>Body Length: Full Length - Head Length</li>
  • </p>
  • https://github.com/seata/seata/issues/893

Variables

View Source
var (
	ErrNotEnoughStream = errors.New("packet stream is not enough")
	ErrTooLargePackage = errors.New("package length is exceed the getty package's legal maximum length.")
	ErrInvalidPackage  = errors.New("invalid rpc package")
	ErrIllegalMagic    = errors.New("package magic is not right.")
)
View Source
var (
	// RpcPkgHandler
	RpcPkgHandler = &RpcPackageHandler{}
)

Functions

This section is empty.

Types

type RpcPackageHandler

type RpcPackageHandler struct{}

func (*RpcPackageHandler) Read

func (p *RpcPackageHandler) Read(ss getty.Session, data []byte) (interface{}, int, error)

Read read binary data from to rpc message

func (*RpcPackageHandler) Write

func (p *RpcPackageHandler) Write(ss getty.Session, pkg interface{}) ([]byte, error)

Write write rpc message to binary data

type SeataV1PackageHeader

type SeataV1PackageHeader struct {
	Magic0       byte
	Magic1       byte
	Version      byte
	TotalLength  uint32
	HeadLength   uint16
	MessageType  byte
	CodecType    byte
	CompressType byte
	ID           uint32
	Meta         map[string]string
	BodyLength   uint32
}

func (*SeataV1PackageHeader) Unmarshal

func (h *SeataV1PackageHeader) Unmarshal(buf *bytes.Buffer) (int, error)

Jump to

Keyboard shortcuts

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