grpc

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TCP = "tcp"
	UDP = "udp"
)

Variables

View Source
var GrpcClient = new(Client)
View Source
var GrpcServer = new(Server)

Functions

func RequestSign

func RequestSign(ts string, secret string) string

func RpcSign

func RpcSign(secret string) (string, int64)

Types

type Client

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

func NewClient

func NewClient() *Client

func (*Client) Close

func (g *Client) Close() error

func (*Client) Connect

func (g *Client) Connect() (*grpc.ClientConn, error)

func (*Client) Init

func (g *Client) Init(address string, token string) *Client

Init 初始化

type CustomCredential

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

CustomCredential 自定义认证

func NewCustomCredential

func NewCustomCredential(token string) *CustomCredential

func (CustomCredential) GetRequestMetadata

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

GetRequestMetadata 实现自定义认证接口

func (CustomCredential) RequireTransportSecurity

func (c CustomCredential) RequireTransportSecurity() bool

RequireTransportSecurity 自定义认证是否开启TLS

type Server

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

func NewServer

func NewServer() *Server

func (*Server) Init

func (g *Server) Init(network, address, token string) *Server

Init 初始化

func (*Server) RegisterServer

func (g *Server) RegisterServer(register ServerRegister) *Server

func (*Server) Start

func (g *Server) Start() error

Start 启动grpc 服务

type ServerRegister

type ServerRegister func(server *grpc.Server)

Jump to

Keyboard shortcuts

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