grpc

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2024 License: MIT Imports: 38 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 Body added in v0.3.0

type Body interface {
	io.Reader
	Scan(obj interface{}) error
}

type Client

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

func NewClient

func NewClient(registrar registry.Registrar, setting *clientConfig, 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(clientCfg *clientConfig) *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请求

type Server added in v0.3.0

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

func (*Server) GetAddr added in v0.3.0

func (e *Server) GetAddr() string

func (*Server) GetProto added in v0.3.0

func (e *Server) GetProto() string

func (*Server) Serve added in v0.3.0

func (e *Server) Serve(ctx context.Context) (err error)

func (*Server) Stop added in v0.3.0

func (e *Server) Stop(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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