msgwriter

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultWriter = "lrpc-trait"

Variables

This section is empty.

Functions

func Register

func Register(scheme string, wf Factory)

Types

type Argument

type Argument struct {
	Message *message.Message
	Conn    transport.ConnAdapter
	Encoder packer.Packer
	// 用于统一内存复用的池, 类型是: *container.Slice[byte]
	Pool *sync.Pool
	// 不为nil时则说明Server开启了Debug模式
	// 为true表示开启了Mux
	OnDebug func([]byte, bool)
	// 在消息发送完成时会调用
	OnComplete func([]byte, perror.LErrorDesc)
	EHandle    perror.LErrors
}

type Factory

type Factory func(writers ...Writer) Writer

func Get

func Get(scheme string) Factory

type JsonRPC2

type JsonRPC2 struct {
	Codec codec.Codec
}

func (*JsonRPC2) Header

func (j *JsonRPC2) Header() []byte

func (*JsonRPC2) Reset

func (j *JsonRPC2) Reset()

func (*JsonRPC2) Write

func (j *JsonRPC2) Write(arg Argument, header byte) perror.LErrorDesc

type Writer

type Writer interface {
	Write(arg Argument, header byte) perror.LErrorDesc
	export.Reset
}

Writer 写入器的实现必须是线程安全的 写入器的抽象与解析器不一样, 解析器要处理multi data & half package 写入器使用的Conn API都是同步的, 所以不用处理half package, 写入器的设计 本身就不能处理多份数据

func NewJsonRPC2

func NewJsonRPC2(writers ...Writer) Writer

func NewLRPCMux

func NewLRPCMux(writers ...Writer) Writer

func NewLRPCNoMux

func NewLRPCNoMux(writers ...Writer) Writer

func NewLRPCTrait

func NewLRPCTrait(writers ...Writer) Writer

Jump to

Keyboard shortcuts

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