grpcservice

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientUnaryInterceptor

func ClientUnaryInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

unaryInterceptor 一个简单的 unary interceptor 示例。

func NewGrpcClientConn added in v0.2.0

func NewGrpcClientConn(opt GrpcClientConnOption) (*grpc.ClientConn, error)

GRPC 客户端创建,优先使用 Addr 配置的地址直连,如果 Addr 未配置,使用 ETCD 服务发现

func ServerStreamInterceptor

func ServerStreamInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

ServerStreamInterceptor is a gRPC server-side interceptor that provides Prometheus monitoring for Streaming RPCs.

func ServerUnaryInterceptor

func ServerUnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)

Types

type GrpcClientConnOption added in v0.2.0

type GrpcClientConnOption struct {
	// addr 和 etcd 二选一
	EtcdKey    string           // * etcd key
	EtcdClient *clientv3.Client // etcd 客户端
	Addr       string           // grcp 服务器地址
}

客户端配置

type GrpcService

type GrpcService struct {
	*zservice.ZService
	GrpcServer *grpc.Server
}

func NewGrpcService

func NewGrpcService(opt GrpcServiceOption) *GrpcService

type GrpcServiceOption added in v0.2.0

type GrpcServiceOption struct {
	EtcdKey    string             // * etcd key
	EtcdClient *clientv3.Client   // etcd 客户端
	GrpcPort   string             // * 监听端口
	OnStart    func(*GrpcService) // 启动的回调
}

服务端配置

Jump to

Keyboard shortcuts

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