ngrpc

package module
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

README

ngrpc

grpc server/client 包装一些grpc功能。

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close 关闭Grpc

func GetSrv

func GetSrv() *grpc.Server

GetSrv 获取rpc server

func Start

func Start(address string)

Start 启动Grpc

Types

type Client

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

Client grpc客户端

func NewClient

func NewClient(serverAddress string, interceptor ...grpc.UnaryClientInterceptor) *Client

NewClient 创建grpc客户端

func NewClientCustomAuthentication

func NewClientCustomAuthentication(serverAddress string, credential credentials.PerRPCCredentials, interceptor ...grpc.UnaryClientInterceptor) *Client

NewClientCustomAuthentication 创建grpc客户端自定义服务验证

func NewClientTLS

func NewClientTLS(serverAddress string, cp *x509.CertPool, serverNameOverride string, interceptor ...grpc.UnaryClientInterceptor) *Client

NewClientTLS 创建grpc客户端

func NewClientTLSCustomAuthentication

func NewClientTLSCustomAuthentication(serverAddress string, cp *x509.CertPool, serverNameOverride string, credential credentials.PerRPCCredentials, interceptor ...grpc.UnaryClientInterceptor) *Client

NewClientTLSCustomAuthentication 创建grpc客户端TLS自定义服务验证

func NewClientTLSFromFile

func NewClientTLSFromFile(serverAddress string, certFile, serverNameOverride string, interceptor ...grpc.UnaryClientInterceptor) *Client

NewClientTLSFromFile 创建grpc客户端TLSFromFile

func NewClientWithBalancer added in v1.2.0

func NewClientWithBalancer(b grpc.Balancer, interceptor ...grpc.UnaryClientInterceptor) *Client

NewClientWithBalancer 创建客户端使用负载均衡

func NewClientWithBalancerName added in v1.2.0

func NewClientWithBalancerName(ctx context.Context, target string, interceptor ...grpc.UnaryClientInterceptor) *Client

NewClientWithBalancerName 创建客户端使用负载均衡

func (*Client) Close

func (c *Client) Close()

Close 关闭

func (*Client) GetConn

func (c *Client) GetConn() *grpc.ClientConn

GetConn 获取客户端连接

type CustomCredential

type CustomCredential struct {
	AppKey, AppSecret string
	Security          bool
}

CustomCredential 自定义凭证

func NewCustomCredential

func NewCustomCredential(appKey, appSecret string, tls bool) *CustomCredential

NewCustomCredential 创建自定义凭证

func (CustomCredential) GetRequestMetadata

func (c CustomCredential) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata Get请求元数据

func (CustomCredential) RequireTransportSecurity

func (c CustomCredential) RequireTransportSecurity() bool

RequireTransportSecurity 是否安全传输

type GetCustomAuthenticationParameter

type GetCustomAuthenticationParameter func() (appID, appKey string)

GetCustomAuthenticationParameter 获取自定义参数

type LocalIPFunc added in v1.3.0

type LocalIPFunc func() string

LocalIPFunc 获取本地IP函数

var (

	// LocalIP 本地IP
	LocalIP LocalIPFunc = consul.LocalIP
)

type Server

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

Server 服务端

func NewServer

func NewServer(address string, interceptor ...grpc.UnaryServerInterceptor) *Server

NewServer 创建服务端

func NewServerCustomAuthentication

func NewServerCustomAuthentication(address string, validation ValidationFunc, interceptor ...grpc.UnaryServerInterceptor) *Server

NewServerCustomAuthentication 创建服务端自定义服务验证

func NewServerTLS

func NewServerTLS(address string, cert *tls.Certificate, interceptor ...grpc.UnaryServerInterceptor) *Server

NewServerTLS 创建服务端TLS

func NewServerTLSCustomAuthentication

func NewServerTLSCustomAuthentication(address string, cert *tls.Certificate, validation ValidationFunc, interceptor ...grpc.UnaryServerInterceptor) *Server

NewServerTLSCustomAuthentication 创建服务端TLS自定义服务验证

func NewServerTLSFromFile

func NewServerTLSFromFile(address string, certFile, keyFile string, interceptor ...grpc.UnaryServerInterceptor) *Server

NewServerTLSFromFile 创建服务端TLSFromFile

func (*Server) Close

func (s *Server) Close()

Close 关闭

func (*Server) GetSrv

func (s *Server) GetSrv() *grpc.Server

GetSrv 获取rpc server

func (*Server) RegisterConsul added in v1.3.0

func (s *Server) RegisterConsul(consulServerAddr string, sInfo *register.ServiceInfo)

RegisterConsul 注册Consul

func (*Server) RegisterService added in v1.4.0

func (s *Server) RegisterService(services ...ServiceRegisterFunc)

RegisterService 注册服务

func (*Server) Start

func (s *Server) Start()

Start 启动

type ServiceRegisterFunc added in v1.4.1

type ServiceRegisterFunc func(s *grpc.Server)

ServiceRegisterFunc 服务注册函数

type ValidationFunc

type ValidationFunc func(appKey, appSecret string) bool

ValidationFunc 验证方法

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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