Documentation
¶
Index ¶
- type ClientPlugin
- type InterceptorPlugin
- type LifecycleHook
- type LifecycleManager
- type Manager
- func (m *Manager) ApplyClientPlugins(opts []grpc.DialOption) []grpc.DialOption
- func (m *Manager) ApplyServerPlugins(server *grpc.Server) error
- func (m *Manager) Close() error
- func (m *Manager) Get(name string) (Plugin, bool)
- func (m *Manager) GetAll() []Plugin
- func (m *Manager) GetByType(pluginType interface{}) []Plugin
- func (m *Manager) GetInterceptors() (unaryServer []grpc.UnaryServerInterceptor, ...)
- func (m *Manager) Init() error
- func (m *Manager) Register(p Plugin) error
- type Plugin
- type ServerPlugin
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientPlugin ¶
type ClientPlugin interface {
Plugin
// ModifyClientOptions 允许插件修改客户端选项
ModifyClientOptions([]grpc.DialOption) []grpc.DialOption
}
ClientPlugin 定义了客户端插件的接口
type InterceptorPlugin ¶
type InterceptorPlugin interface {
Plugin
// UnaryServerInterceptor 返回一个一元服务端拦截器
UnaryServerInterceptor() grpc.UnaryServerInterceptor
// StreamServerInterceptor 返回一个流服务端拦截器
StreamServerInterceptor() grpc.StreamServerInterceptor
// UnaryClientInterceptor 返回一个一元客户端拦截器
UnaryClientInterceptor() grpc.UnaryClientInterceptor
// StreamClientInterceptor 返回一个流客户端拦截器
StreamClientInterceptor() grpc.StreamClientInterceptor
}
InterceptorPlugin 定义了拦截器插件的接口
type LifecycleHook ¶
type LifecycleHook interface {
// BeforeStart 在服务启动前调用
BeforeStart(context.Context) error
// AfterStart 在服务启动后调用
AfterStart(context.Context) error
// BeforeStop 在服务停止前调用
BeforeStop(context.Context) error
// AfterStop 在服务停止后调用
AfterStop(context.Context) error
}
LifecycleHook 定义了插件生命周期钩子
type LifecycleManager ¶
type LifecycleManager struct {
// contains filtered or unexported fields
}
LifecycleManager 管理插件的生命周期事件
func NewLifecycleManager ¶
func NewLifecycleManager(manager *Manager) *LifecycleManager
NewLifecycleManager 创建一个新的生命周期管理器
func (*LifecycleManager) ExecuteAfterStart ¶
func (lm *LifecycleManager) ExecuteAfterStart(ctx context.Context) error
ExecuteAfterStart 执行所有插件的AfterStart钩子
func (*LifecycleManager) ExecuteAfterStop ¶
func (lm *LifecycleManager) ExecuteAfterStop(ctx context.Context) error
ExecuteAfterStop 执行所有插件的AfterStop钩子
func (*LifecycleManager) ExecuteBeforeStart ¶
func (lm *LifecycleManager) ExecuteBeforeStart(ctx context.Context) error
ExecuteBeforeStart 执行所有插件的BeforeStart钩子
func (*LifecycleManager) ExecuteBeforeStop ¶
func (lm *LifecycleManager) ExecuteBeforeStop(ctx context.Context) error
ExecuteBeforeStop 执行所有插件的BeforeStop钩子
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager 管理所有已注册的插件
func (*Manager) ApplyClientPlugins ¶
func (m *Manager) ApplyClientPlugins(opts []grpc.DialOption) []grpc.DialOption
ApplyClientPlugins 将所有客户端插件应用到gRPC客户端选项
func (*Manager) ApplyServerPlugins ¶
ApplyServerPlugins 将所有服务端插件应用到gRPC服务器
func (*Manager) GetInterceptors ¶
func (m *Manager) GetInterceptors() ( unaryServer []grpc.UnaryServerInterceptor, streamServer []grpc.StreamServerInterceptor, unaryClient []grpc.UnaryClientInterceptor, streamClient []grpc.StreamClientInterceptor, )
GetInterceptors 获取所有拦截器插件的拦截器
Click to show internal directories.
Click to hide internal directories.