github.com/grafana/pyroscope@v1.18.0/pkg/querier/grpc_handler.go (about) 1 package querier 2 3 import ( 4 "net/http" 5 6 "github.com/grafana/pyroscope/api/gen/proto/go/querier/v1/querierv1connect" 7 connectapi "github.com/grafana/pyroscope/pkg/api/connect" 8 "github.com/grafana/pyroscope/pkg/util/connectgrpc" 9 httputil "github.com/grafana/pyroscope/pkg/util/http" 10 ) 11 12 type QuerierSvc interface { 13 querierv1connect.QuerierServiceHandler 14 } 15 16 func NewGRPCHandler(svc QuerierSvc, useK6Middleware bool) connectgrpc.GRPCHandler { 17 mux := http.NewServeMux() 18 mux.Handle(querierv1connect.NewQuerierServiceHandler(svc, connectapi.DefaultHandlerOptions()...)) 19 20 if useK6Middleware { 21 httpMiddleware := httputil.K6Middleware() 22 return connectgrpc.NewHandler(httpMiddleware.Wrap(mux)) 23 } 24 25 return connectgrpc.NewHandler(mux) 26 }