Documentation
¶
Index ¶
- type Config
- type Credential
- type Grpc
- func (g *Grpc) CloseClient(conn *grpc.ClientConn)
- func (g *Grpc) GetAuthInterceptor(username, password string) grpc.ServerOption
- func (g *Grpc) GetClientConn() (conn *grpc.ClientConn, err error)
- func (g *Grpc) GetInterceptor(beforeFunc func(ctx context.Context) error, ...) grpc.ServerOption
- func (g *Grpc) RunServer(...)
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Debug bool `yaml:"debug" json:"debug"` // 是否为debug模式
LogFilePath string `yaml:"log_file_path" json:"log_file_path"` // 日志路径
ListenType string `yaml:"listen_type" json:"listen"` // 监听类型:默认tcp,还支持tcp4/tcp6/unix/unixpacket
Server Server `yaml:"server" json:"server"` // 服务器配置
Client Server `yaml:"client" json:"client"` // 客户端配置
}
type Credential ¶
func (Credential) GetRequestMetadata ¶
func (c Credential) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)
GetRequestMetadata 设置metadata
func (Credential) RequireTransportSecurity ¶
func (c Credential) RequireTransportSecurity() bool
RequireTransportSecurity 是否使用安全协议
type Grpc ¶
type Grpc struct {
Log *zdpgo_log.Log // 日志对象
Config *Config // 配置对象
Credential *Credential // 自定义校验对象
}
Grpc 核心对象
func NewWithConfig ¶
func (*Grpc) CloseClient ¶
func (g *Grpc) CloseClient(conn *grpc.ClientConn)
func (*Grpc) GetAuthInterceptor ¶
func (g *Grpc) GetAuthInterceptor(username, password string) grpc.ServerOption
GetAuthInterceptor 设置权限校验拦截器
func (*Grpc) GetClientConn ¶
func (g *Grpc) GetClientConn() (conn *grpc.ClientConn, err error)
GetClientConn 获取GRPC客户端连接
func (*Grpc) GetInterceptor ¶
func (g *Grpc) GetInterceptor(beforeFunc func(ctx context.Context) error, afterFunc func(ctx context.Context)) grpc.ServerOption
GetInterceptor 获取拦截器
func (*Grpc) RunServer ¶
func (g *Grpc) RunServer( registerFunc func(grpcServerRegister grpc.ServiceRegistrar, implGrpcServer interface{}), implServerArg interface{}, interceptors ...grpc.ServerOption, )
RunServer 运行GRPC服务
Source Files
¶
Click to show internal directories.
Click to hide internal directories.