Documentation ¶
Index ¶
- func Close()
- func GetSrv() *grpc.Server
- func Start(address string)
- type Client
- func NewClient(serverAddress string, interceptor ...grpc.UnaryClientInterceptor) *Client
- func NewClientCustomAuthentication(serverAddress string, credential credentials.PerRPCCredentials, ...) *Client
- func NewClientTLS(serverAddress string, cp *x509.CertPool, serverNameOverride string, ...) *Client
- func NewClientTLSCustomAuthentication(serverAddress string, cp *x509.CertPool, serverNameOverride string, ...) *Client
- func NewClientTLSFromFile(serverAddress string, certFile, serverNameOverride string, ...) *Client
- func NewClientWithBalancer(b grpc.Balancer, interceptor ...grpc.UnaryClientInterceptor) *Client
- func NewClientWithBalancerName(ctx context.Context, target string, interceptor ...grpc.UnaryClientInterceptor) *Client
- type CustomCredential
- type GetCustomAuthenticationParameter
- type LocalIPFunc
- type Server
- func NewServer(address string, interceptor ...grpc.UnaryServerInterceptor) *Server
- func NewServerCustomAuthentication(address string, validation ValidationFunc, ...) *Server
- func NewServerTLS(address string, cert *tls.Certificate, ...) *Server
- func NewServerTLSCustomAuthentication(address string, cert *tls.Certificate, validation ValidationFunc, ...) *Server
- func NewServerTLSFromFile(address string, certFile, keyFile string, ...) *Server
- type ServiceRegisterFunc
- type ValidationFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 创建客户端使用负载均衡
type CustomCredential ¶
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) 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 注册服务
type ServiceRegisterFunc ¶ added in v1.4.1
ServiceRegisterFunc 服务注册函数