zrpc

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(hostPort string, lis net.Listener) (string, error)

Extract returns a private addr and port.

func ExtractHostPort

func ExtractHostPort(addr string) (host string, port uint64, err error)

ExtractHostPort from address

func NewEndpoint

func NewEndpoint(scheme, host string, isSecure bool) *url.URL

NewEndpoint new an Endpoint URL.

func Port

func Port(lis net.Listener) (int, bool)

Port return a real port.

Types

type ClientInter

type ClientInter interface {
	Conn() *grpc.ClientConn
}

func NewClient

func NewClient(target string, opts ...ClientOptionFunc) (ClientInter, error)

NewClient returns a Client.

func NewRpcClient

func NewRpcClient(c *gofkConf.RpcClientConf) ClientInter

NewRpcClient returns a Client, exits on any error.

type ClientOptionFunc

type ClientOptionFunc func(o *clientOptions)

func WithDialOption

func WithDialOption(opt grpc.DialOption) ClientOptionFunc

func WithEndpoint

func WithEndpoint(endpoint string) ClientOptionFunc

func WithNonBlock

func WithNonBlock() ClientOptionFunc

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOptionFunc

WithTimeout returns a func to customize a ClientOptions with given timeout.

func WithTransportCredentials

func WithTransportCredentials(creds credentials.TransportCredentials) ClientOptionFunc

WithTransportCredentials return a func to make the gRPC calls secured with given credentials.

type RpcClient

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

func (*RpcClient) Conn

func (rc *RpcClient) Conn() *grpc.ClientConn

Conn returns the underlying grpc.ClientConn.

type RpcInter

type RpcInter interface {
	AddGrpcOptions(options ...grpc.ServerOption)
	AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)
	AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)
	Start()
	Stop()
}

type RpcRegisterInter

type RpcRegisterInter interface {
	RegisterServer(*Server)
}

type RpcServer

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

func NewRpcServer

func NewRpcServer(conf *pkgConf.Config) *RpcServer

func (*RpcServer) AddGrpcOptions

func (rs *RpcServer) AddGrpcOptions(options ...grpc.ServerOption)

AddGrpcOptions adds given options.

func (*RpcServer) AddStreamInterceptors

func (rs *RpcServer) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)

AddStreamInterceptors adds given stream interceptors.

func (*RpcServer) AddUnaryInterceptors

func (rs *RpcServer) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)

AddUnaryInterceptors adds given unary interceptors.

func (*RpcServer) Endpoint

func (rs *RpcServer) Endpoint() (*url.URL, error)

Endpoint return url

func (*RpcServer) Register

func (rs *RpcServer) Register(inters ...RpcRegisterInter)

Register 注册

func (*RpcServer) Start

func (rs *RpcServer) Start()

Start start the RpcServer.

func (*RpcServer) Stop

func (rs *RpcServer) Stop()

Stop stops the RpcServer.

type Server

type Server struct {
	*grpc.Server
	Opts *serverOption

	Endpoint *url.URL

	Registers []RpcRegisterInter
	// contains filtered or unexported fields
}

func (*Server) AddGrpcOptions

func (s *Server) AddGrpcOptions(options ...grpc.ServerOption)

func (*Server) AddStreamInterceptors

func (s *Server) AddStreamInterceptors(interceptors ...grpc.StreamServerInterceptor)

func (*Server) AddUnaryInterceptors

func (s *Server) AddUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor)

func (*Server) Start

func (s *Server) Start() error

Start start the gRPC server.

func (*Server) Stop

func (s *Server) Stop() error

Stop stop the gRPC server.

type SvrOptionFunc

type SvrOptionFunc func(option *serverOption)

func ServerLoad

func ServerLoad(config *gofkConf.Config) (opts []SvrOptionFunc)

ServerLoad 加载依赖项

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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