shim: change ttrpcService and ttrpcServerOptioner to exported interfaces

Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
This commit is contained in:
Iceber Gu
2023-06-27 18:13:16 +08:00
parent d5ec7286ae
commit 00e5ae2118
5 changed files with 21 additions and 10 deletions

View File

@@ -100,12 +100,12 @@ type Config struct {
NoSetupLogger bool
}
type ttrpcService interface {
type TTRPCService interface {
RegisterTTRPC(*ttrpc.Server) error
}
type ttrpcServerOptioner interface {
ttrpcService
type TTRPCServerOptioner interface {
TTRPCService
UnaryInterceptor() ttrpc.UnaryServerInterceptor
}
@@ -302,7 +302,7 @@ func run(ctx context.Context, manager Manager, name string, config Config) error
var (
initialized = plugin.NewPluginSet()
ttrpcServices = []ttrpcService{}
ttrpcServices = []TTRPCService{}
ttrpcUnaryInterceptors = []ttrpc.UnaryServerInterceptor{}
)
@@ -349,13 +349,13 @@ func run(ctx context.Context, manager Manager, name string, config Config) error
return fmt.Errorf("failed to load plugin %s: %w", id, err)
}
if src, ok := instance.(ttrpcService); ok {
if src, ok := instance.(TTRPCService); ok {
logrus.WithField("id", id).Debug("registering ttrpc service")
ttrpcServices = append(ttrpcServices, src)
}
if src, ok := instance.(ttrpcServerOptioner); ok {
if src, ok := instance.(TTRPCServerOptioner); ok {
ttrpcUnaryInterceptors = append(ttrpcUnaryInterceptors, src.UnaryInterceptor())
}
}