apache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Overview

Package apache contains code for working with apache thrift indirectly

It acts as a bridge between generated code which relies on apache codec like:

Write(p thrift.TProtocol) error
Read(p thrift.TProtocol) error

and kitex ecosystem.

Because we're deprecating apache thrift, all kitex ecosystem code will not rely on apache thrift except one pkg: `github.com/cloudwego/kitex/pkg/protocol/bthrift`. Why is the package chosen? All legacy generated code relies on it, and we may not be able to update the code in a brief timeframe. So the package is chosen to register `thrift.NewTBinaryProtocol` to this package in order to use it without importing `github.com/apache/thrift`

ThriftRead or ThriftWrite is implemented for calling Read/Write without knowing the interface of `thrift.TProtocol`. Since we already have `thrift.NewTBinaryProtocol`, we only need to check: if the return value of `thrift.NewTBinaryProtocol` implements the input which is `thrift.TProtocol` of Read/Write

For new generated code, it no longer uses the `github.com/cloudwego/kitex/pkg/protocol/bthrift`

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterNewTBinaryProtocol

func RegisterNewTBinaryProtocol(fn interface{}) error

RegisterNewTBinaryProtocol accepts `thrift.NewTBinaryProtocol` func and save it for later use.

func ThriftRead

func ThriftRead(t TTransport, v interface{}) error

ThriftRead calls Read method of v.

RegisterNewTBinaryProtocol must be called with `thrift.NewTBinaryProtocol` before using this func.

func ThriftWrite

func ThriftWrite(t TTransport, v interface{}) error

ThriftWrite calls Write method of v.

RegisterNewTBinaryProtocol must be called with `thrift.NewTBinaryProtocol` before using this func.

Types

type BufferTransport

type BufferTransport struct {
	*bytes.Buffer
}

BufferTransport extends bytes.Buffer to support TTransport

func (BufferTransport) Close

func (p BufferTransport) Close() error

func (BufferTransport) Flush

func (p BufferTransport) Flush(_ context.Context) error

func (BufferTransport) IsOpen

func (p BufferTransport) IsOpen() bool

func (BufferTransport) Open

func (p BufferTransport) Open() error

func (BufferTransport) RemainingBytes

func (p BufferTransport) RemainingBytes() uint64

type TTransport

type TTransport interface {
	io.ReadWriteCloser
	RemainingBytes() (num_bytes uint64)
	Flush(ctx context.Context) (err error)
	Open() error
	IsOpen() bool
}

TTransport is identical with thrift.TTransport.

Jump to

Keyboard shortcuts

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