tgrpc

package
v0.0.0-...-d4bbc0e Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 16 Imported by: 0

README

GrpcWrapper-tgrpc

基于grpc进行封装,支持服务发现,服务注册,负载均衡,服务治理等功能。

  • go watch: 获取etcd最新状态,更新DownServices,进而更新solver
  • run: 监听两个channel,注册/删除 推到etcd上,且做注册/续期

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PClient

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

func NewClient

func NewClient(serviceName string, interceptors ...grpc.UnaryClientInterceptor) (*PClient, error)

func (*PClient) Conn

func (p *PClient) Conn() *grpc.ClientConn

func (*PClient) DialByEndPoint

func (p *PClient) DialByEndPoint(adrss string) (*grpc.ClientConn, error)

type PServer

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

func NewServer

func NewServer(opts ...ServerOption) *PServer

func (*PServer) RegisterService

func (p *PServer) RegisterService(register ...RegisterFn)

eg :

p.RegisterService(func(server *grpc.Server) {
    test.RegisterGreeterServer(server, &Server{})
})

func (*PServer) RegisterUnaryServerInterceptor

func (p *PServer) RegisterUnaryServerInterceptor(i grpc.UnaryServerInterceptor)

注册自定义拦截器,例如限流拦截器或者自己的一些业务自定义拦截器

func (*PServer) Start

func (p *PServer) Start(ctx context.Context)

开启server

type RegisterFn

type RegisterFn func(*grpc.Server)

type ServerOption

type ServerOption func(opts *serverOptions)

func WithHealth

func WithHealth(health bool) ServerOption

set health

func WithIP

func WithIP(ip string) ServerOption

set ip

func WithPort

func WithPort(port int) ServerOption

set port

func WithServiceName

func WithServiceName(serviceName string) ServerOption

set serviceName

func WithWeight

func WithWeight(weight int) ServerOption

set weight

Directories

Path Synopsis
example
interceptor

Jump to

Keyboard shortcuts

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