mirror of
https://github.com/grafana/grafana.git
synced 2024-12-26 00:41:20 -06:00
bc2813ef06
* fix goimports * fix goimports order
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package grpcserver
|
|
|
|
import (
|
|
"context"
|
|
|
|
"google.golang.org/grpc/reflection"
|
|
"google.golang.org/grpc/reflection/grpc_reflection_v1alpha"
|
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
|
)
|
|
|
|
// 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
|
|
}
|