rpc

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(ctx context.Context, opts ...ClientOption) (*grpc.ClientConn, error)

Dial 返回GRPC连接.

func DialInsecure

func DialInsecure(ctx context.Context, opts ...ClientOption) (*grpc.ClientConn, error)

DialInsecure 返回不安全的GRPC连接.

func NewClientContext

func NewClientContext(ctx context.Context, info ClientInfo) context.Context

NewClientContext 返回一个带有值(ClientInfo)的新Context.

func NewServerContext

func NewServerContext(ctx context.Context, info ServerInfo) context.Context

NewServerContext 返回一个带有值(ServerInfo)的新Context.

Types

type ClientInfo

type ClientInfo struct {
	// FullMethod 是完整的RPC方法字符串,即/package.service/method.
	FullMethod string
}

ClientInfo 表示gRPC服务器信息.

func FromClientContext

func FromClientContext(ctx context.Context) (info ClientInfo, ok bool)

FromClientContext 返回存储在ctx中的传输值(如果有).

type ClientOption

type ClientOption func(o *clientOptions)

ClientOption 是gRPC客户端选项.

func WithDiscovery

func WithDiscovery(d registry.Discovery) ClientOption

WithDiscovery 带客户端服务发现.

func WithEndpoint

func WithEndpoint(endpoint string) ClientOption

WithEndpoint 带客户端节点设置.

func WithMiddleware

func WithMiddleware(m middleware.Middleware) ClientOption

WithMiddleware 带客户端中间件.

func WithOptions

func WithOptions(opts ...grpc.DialOption) ClientOption

WithOptions 带gRPC选项的.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout 带客户端超时设置.

type Server

type Server struct {
	*grpc.Server
	// contains filtered or unexported fields
}

Server 是一个gRPC服务器包装器.

func NewServer

func NewServer(opts ...ServerOption) *Server

NewServer 通过选项创建一个gRPC服务器.

func (*Server) Endpoint

func (s *Server) Endpoint() (*url.URL, error)

Endpoint 返回真实地址到注册表节点. examples:

grpc://127.0.0.1:9090?isSecure=false

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start 启动gRPC服务器.

func (*Server) Stop

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

Stop 停止gRPC服务器.

type ServerInfo

type ServerInfo struct {
	// Server 是用户提供的服务实现.这是只读的.
	Server interface{}
	// FullMethod 是完整的RPC方法字符串,即/package.service/method.
	FullMethod string
}

ServerInfo 表示gRPC服务器信息.

func FromServerContext

func FromServerContext(ctx context.Context) (info ServerInfo, ok bool)

FromServerContext 返回存储在ctx中的传输值(如果有).

type ServerOption

type ServerOption func(o *Server)

ServerOption 是gRPC服务器选项.

func Address

func Address(addr string) ServerOption

Address 返回带服务器地址选项.

func Logger

func Logger(logger log.Logger) ServerOption

Logger 返回带有定制日记适配器选项.

func Middleware

func Middleware(m ...middleware.Middleware) ServerOption

Middleware 返回带服务器中间件选项.

func Network

func Network(network string) ServerOption

Network 返回带服务器网络协议选项.

func Options

func Options(opts ...grpc.ServerOption) ServerOption

Options 返回带有grpc选项.

func Timeout

func Timeout(timeout time.Duration) ServerOption

Timeout 返回带服务器超时选项.

func UnaryInterceptor

func UnaryInterceptor(in ...grpc.UnaryServerInterceptor) ServerOption

UnaryInterceptor 返回一个带服务器UnaryServerInterceptor选项.

Directories

Path Synopsis
resolver

Jump to

Keyboard shortcuts

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