Documentation ¶
Index ¶
- func ClientUnaryInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, ...) error
- func NewGrpcClientConn(opt GrpcClientConnOption) (*grpc.ClientConn, error)
- func ServerStreamInterceptor(srv any, ss grpc.ServerStream, info *grpc.StreamServerInfo, ...) error
- func ServerUnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, ...) (any, error)
- type GrpcClientConnOption
- type GrpcService
- type GrpcServiceOption
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 ¶
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) // 启动的回调 }
服务端配置
Click to show internal directories.
Click to hide internal directories.