Documentation ¶
Index ¶
- Constants
- func ClientUnaryInterceptor(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, ...) error
- func NewGrpcClient(opt *GrpcClientOption) (*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 GrpcClientOption
- type GrpcService
- type GrpcServiceConfig
Constants ¶
View Source
const (
S_ServiceName = "/zservice/services/%s"
)
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 NewGrpcClient ¶
func NewGrpcClient(opt *GrpcClientOption) (*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 GrpcClientOption ¶
type GrpcService ¶
func NewGrpcService ¶
func NewGrpcService(c *GrpcServiceConfig) *GrpcService
type GrpcServiceConfig ¶
type GrpcServiceConfig struct { ListenPort string // 监听端口 EtcdClient *clientv3.Client OnStart func(*GrpcService) // 启动的回调 }
Click to show internal directories.
Click to hide internal directories.