grpc

package
v0.1.24 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2022 License: MIT Imports: 25 Imported by: 2

Documentation

Index

Constants

View Source
const Proto = "grpc"
View Source
const Snappy = "snappy"

Snappy is the name registered for the snappy Compressor.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(registrar registry.Registrar, setting *setting, reqPath *url.URL) (*Client, error)

NewClient 创建RPC客户端,地址是远程RPC服务器地址或注册中心地址

func (*Client) Close

func (c *Client) Close()

Close 关闭RPC客户端连接

func (*Client) RequestByString

func (c *Client) RequestByString(ctx context.Context, input []byte, opts ...xrpc.RequestOption) (res xrpc.Body, err error)

RequestByString 发送Request请求

type Compressor

type Compressor struct {
}

func (*Compressor) Compress

func (c *Compressor) Compress(w io.Writer) (io.WriteCloser, error)

func (*Compressor) Decompress

func (c *Compressor) Decompress(r io.Reader) (io.Reader, error)

func (*Compressor) Name

func (c *Compressor) Name() string

type Request

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

Request RPC Request

func NewRequest

func NewRequest(setting *setting) *Request

NewRequest 构建请求

func (*Request) Close

func (r *Request) Close() error

Close 关闭RPC连接

func (*Request) Request

func (r *Request) Request(ctx sctx.Context, service string, input interface{}, opts ...xrpc.RequestOption) (res xrpc.Body, err error)

RequestByCtx RPC请求,可通过context撤销请求 service=grpc://servername/path

func (*Request) Swap

func (r *Request) Swap(ctx context.Context, service string, opts ...xrpc.RequestOption) (res xrpc.Body, err error)

Swap 将当前请求参数作为RPC参数并发送RPC请求

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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