ttstream

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: Apache-2.0 Imports: 36 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidStreamKind = errors.New("invalid stream kind")
	ErrClosedStream      = errors.New("stream is closed")
	ErrCanceledStream    = errors.New("stream is canceled")
)
View Source
var DefaultLongConnConfig = LongConnConfig{
	MaxIdleTimeout: time.Minute,
}
View Source
var DefaultMuxConnConfig = MuxConnConfig{
	PoolSize:       runtime.GOMAXPROCS(0),
	MaxIdleTimeout: time.Minute,
}

Functions

func DecodePayload

func DecodePayload(ctx context.Context, payload []byte, msg any) error

func EncodeException

func EncodeException(ctx context.Context, method string, seq int32, ex error) ([]byte, error)

func EncodeFrame

func EncodeFrame(ctx context.Context, writer bufiox.Writer, fr *Frame) (err error)

EncodeFrame will not call Flush!

func EncodePayload

func EncodePayload(ctx context.Context, msg any) ([]byte, error)

func NewCliTransHandlerFactory added in v0.15.0

func NewCliTransHandlerFactory(opts ...ClientHandlerOption) remote.ClientStreamFactory

NewCliTransHandlerFactory return a client trans handler factory.

func NewSvrTransHandlerFactory added in v0.14.0

func NewSvrTransHandlerFactory() remote.ServerTransHandlerFactory

NewSvrTransHandlerFactory ...

Types

type ClientHandlerOption added in v0.15.0

type ClientHandlerOption func(cp *clientTransHandler)

ClientHandlerOption define client handler options

func WithClientHeaderFrameHandler

func WithClientHeaderFrameHandler(handler HeaderFrameWriteHandler) ClientHandlerOption

WithClientHeaderFrameHandler register TTHeader Streaming header frame handler

func WithClientLongConnPool

func WithClientLongConnPool(config LongConnConfig) ClientHandlerOption

WithClientLongConnPool using long connection pool for client

func WithClientMetaFrameHandler

func WithClientMetaFrameHandler(handler MetaFrameHandler) ClientHandlerOption

WithClientMetaFrameHandler register TTHeader Streaming meta frame handler

func WithClientMuxConnPool

func WithClientMuxConnPool(config MuxConnConfig) ClientHandlerOption

WithClientMuxConnPool using mux connection pool for client

func WithClientShortConnPool

func WithClientShortConnPool() ClientHandlerOption

WithClientShortConnPool using short connection pool for client

func WithClientTraceController added in v0.16.0

func WithClientTraceController(traceCtl *rpcinfo.TraceController) ClientHandlerOption

WithClientTraceController configures TraceController to report detailed streaming events

type ClientProviderOption deprecated

type ClientProviderOption = ClientHandlerOption

Deprecated: use ClientHandlerOption instead

type ClientStreamMeta

type ClientStreamMeta interface {
	streaming.ClientStream
	Header() (streaming.Header, error)
	Trailer() (streaming.Trailer, error)
}

ClientStreamMeta cannot send header directly, should send from ctx

type Exception added in v0.15.0

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

func (*Exception) Error added in v0.15.0

func (e *Exception) Error() string

func (*Exception) Is added in v0.15.0

func (e *Exception) Is(target error) bool

func (*Exception) TypeId added in v0.15.0

func (e *Exception) TypeId() int32

type Frame

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

Frame define a TTHeader Streaming Frame

func DecodeFrame

func DecodeFrame(ctx context.Context, reader bufiox.Reader) (fr *Frame, err error)

func (*Frame) String

func (f *Frame) String() string

type HeaderFrameHandler

type HeaderFrameHandler interface {
	HeaderFrameReadHandler
	HeaderFrameWriteHandler
}

type HeaderFrameReadHandler

type HeaderFrameReadHandler interface {
	OnReadStream(ctx context.Context, ihd IntHeader, shd StrHeader) (context.Context, error)
}

type HeaderFrameWriteHandler

type HeaderFrameWriteHandler interface {
	OnWriteStream(ctx context.Context) (ihd IntHeader, shd StrHeader, err error)
}

type IntHeader

type IntHeader map[uint16]string

only for meta frame handler

type LongConnConfig

type LongConnConfig struct {
	MaxIdleTimeout time.Duration
}

type MetaFrameHandler

type MetaFrameHandler interface {
	OnMetaFrame(ctx context.Context, intHeader IntHeader, header streaming.Header, payload []byte) error
}

type MuxConnConfig

type MuxConnConfig struct {
	PoolSize       int
	MaxIdleTimeout time.Duration
}

type ServerHandlerOption added in v0.15.0

type ServerHandlerOption func(pc *svrTransHandler)

ServerHandlerOption define server provider options

func WithServerHeaderFrameHandler

func WithServerHeaderFrameHandler(handler HeaderFrameReadHandler) ServerHandlerOption

WithServerHeaderFrameHandler register TTHeader Streaming header frame handler

type ServerProviderOption deprecated

type ServerProviderOption = ServerHandlerOption

Deprecated: use ServerHandlerOption instead

type ServerStreamMeta

type ServerStreamMeta interface {
	streaming.ServerStream
	SetHeader(hd streaming.Header) error
	SendHeader(hd streaming.Header) error
	SetTrailer(hd streaming.Trailer) error
}

ServerStreamMeta cannot read header directly, should read from ctx

type StrHeader

type StrHeader = streaming.Header

only for meta frame handler

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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