mirror of https://github.com/grafana/grafana
GRPC Server: Move reflection to a separate gRPC service (#55872)
parent
e8ac52ba0f
commit
a281c26580
@ -0,0 +1,35 @@ |
|||||||
|
package grpcserver |
||||||
|
|
||||||
|
import ( |
||||||
|
"context" |
||||||
|
|
||||||
|
"github.com/grafana/grafana/pkg/setting" |
||||||
|
|
||||||
|
"google.golang.org/grpc/reflection" |
||||||
|
"google.golang.org/grpc/reflection/grpc_reflection_v1alpha" |
||||||
|
) |
||||||
|
|
||||||
|
// ReflectionService implements the gRPC Server Reflection Protocol:
|
||||||
|
// https://github.com/grpc/grpc/blob/master/doc/server-reflection.md
|
||||||
|
type ReflectionService struct { |
||||||
|
cfg *setting.Cfg |
||||||
|
reflectionServer *reflectionServer |
||||||
|
} |
||||||
|
|
||||||
|
type reflectionServer struct { |
||||||
|
grpc_reflection_v1alpha.ServerReflectionServer |
||||||
|
} |
||||||
|
|
||||||
|
// AuthFuncOverride no auth for reflection service.
|
||||||
|
func (s *reflectionServer) AuthFuncOverride(ctx context.Context, _ string) (context.Context, error) { |
||||||
|
return ctx, nil |
||||||
|
} |
||||||
|
|
||||||
|
func ProvideReflectionService(cfg *setting.Cfg, grpcServerProvider Provider) (*ReflectionService, error) { |
||||||
|
re := &reflectionServer{reflection.NewServer(reflection.ServerOptions{Services: grpcServerProvider.GetServer()})} |
||||||
|
grpc_reflection_v1alpha.RegisterServerReflectionServer(grpcServerProvider.GetServer(), re) |
||||||
|
return &ReflectionService{ |
||||||
|
cfg: cfg, |
||||||
|
reflectionServer: re, |
||||||
|
}, nil |
||||||
|
} |
||||||
Loading…
Reference in new issue