github.com/grafana/pyroscope@v1.18.0/pkg/frontend/frontendpb/frontendpbconnect/frontend.connect.go (about) 1 // SPDX-License-Identifier: AGPL-3.0-only 2 // Provenance-includes-location: https://github.com/cortexproject/cortex/blob/master/pkg/frontend/v2/frontendv2pb/frontend.proto 3 // Provenance-includes-license: Apache-2.0 4 // Provenance-includes-copyright: The Cortex Authors. 5 6 // Code generated by protoc-gen-connect-go. DO NOT EDIT. 7 // 8 // Source: frontend/frontendpb/frontend.proto 9 10 package frontendpbconnect 11 12 import ( 13 connect "connectrpc.com/connect" 14 context "context" 15 errors "errors" 16 frontendpb "github.com/grafana/pyroscope/pkg/frontend/frontendpb" 17 http "net/http" 18 strings "strings" 19 ) 20 21 // This is a compile-time assertion to ensure that this generated file and the connect package are 22 // compatible. If you get a compiler error that this constant is not defined, this code was 23 // generated with a version of connect newer than the one compiled into your binary. You can fix the 24 // problem by either regenerating this code with an older version of connect or updating the connect 25 // version compiled into your binary. 26 const _ = connect.IsAtLeastVersion1_13_0 27 28 const ( 29 // FrontendForQuerierName is the fully-qualified name of the FrontendForQuerier service. 30 FrontendForQuerierName = "frontendpb.FrontendForQuerier" 31 ) 32 33 // These constants are the fully-qualified names of the RPCs defined in this package. They're 34 // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. 35 // 36 // Note that these are different from the fully-qualified method names used by 37 // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to 38 // reflection-formatted method names, remove the leading slash and convert the remaining slash to a 39 // period. 40 const ( 41 // FrontendForQuerierQueryResultProcedure is the fully-qualified name of the FrontendForQuerier's 42 // QueryResult RPC. 43 FrontendForQuerierQueryResultProcedure = "/frontendpb.FrontendForQuerier/QueryResult" 44 ) 45 46 // FrontendForQuerierClient is a client for the frontendpb.FrontendForQuerier service. 47 type FrontendForQuerierClient interface { 48 QueryResult(context.Context, *connect.Request[frontendpb.QueryResultRequest]) (*connect.Response[frontendpb.QueryResultResponse], error) 49 } 50 51 // NewFrontendForQuerierClient constructs a client for the frontendpb.FrontendForQuerier service. By 52 // default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, 53 // and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the 54 // connect.WithGRPC() or connect.WithGRPCWeb() options. 55 // 56 // The URL supplied here should be the base URL for the Connect or gRPC server (for example, 57 // http://api.acme.com or https://acme.com/grpc). 58 func NewFrontendForQuerierClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) FrontendForQuerierClient { 59 baseURL = strings.TrimRight(baseURL, "/") 60 frontendForQuerierMethods := frontendpb.File_frontend_frontendpb_frontend_proto.Services().ByName("FrontendForQuerier").Methods() 61 return &frontendForQuerierClient{ 62 queryResult: connect.NewClient[frontendpb.QueryResultRequest, frontendpb.QueryResultResponse]( 63 httpClient, 64 baseURL+FrontendForQuerierQueryResultProcedure, 65 connect.WithSchema(frontendForQuerierMethods.ByName("QueryResult")), 66 connect.WithClientOptions(opts...), 67 ), 68 } 69 } 70 71 // frontendForQuerierClient implements FrontendForQuerierClient. 72 type frontendForQuerierClient struct { 73 queryResult *connect.Client[frontendpb.QueryResultRequest, frontendpb.QueryResultResponse] 74 } 75 76 // QueryResult calls frontendpb.FrontendForQuerier.QueryResult. 77 func (c *frontendForQuerierClient) QueryResult(ctx context.Context, req *connect.Request[frontendpb.QueryResultRequest]) (*connect.Response[frontendpb.QueryResultResponse], error) { 78 return c.queryResult.CallUnary(ctx, req) 79 } 80 81 // FrontendForQuerierHandler is an implementation of the frontendpb.FrontendForQuerier service. 82 type FrontendForQuerierHandler interface { 83 QueryResult(context.Context, *connect.Request[frontendpb.QueryResultRequest]) (*connect.Response[frontendpb.QueryResultResponse], error) 84 } 85 86 // NewFrontendForQuerierHandler builds an HTTP handler from the service implementation. It returns 87 // the path on which to mount the handler and the handler itself. 88 // 89 // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf 90 // and JSON codecs. They also support gzip compression. 91 func NewFrontendForQuerierHandler(svc FrontendForQuerierHandler, opts ...connect.HandlerOption) (string, http.Handler) { 92 frontendForQuerierMethods := frontendpb.File_frontend_frontendpb_frontend_proto.Services().ByName("FrontendForQuerier").Methods() 93 frontendForQuerierQueryResultHandler := connect.NewUnaryHandler( 94 FrontendForQuerierQueryResultProcedure, 95 svc.QueryResult, 96 connect.WithSchema(frontendForQuerierMethods.ByName("QueryResult")), 97 connect.WithHandlerOptions(opts...), 98 ) 99 return "/frontendpb.FrontendForQuerier/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 100 switch r.URL.Path { 101 case FrontendForQuerierQueryResultProcedure: 102 frontendForQuerierQueryResultHandler.ServeHTTP(w, r) 103 default: 104 http.NotFound(w, r) 105 } 106 }) 107 } 108 109 // UnimplementedFrontendForQuerierHandler returns CodeUnimplemented from all methods. 110 type UnimplementedFrontendForQuerierHandler struct{} 111 112 func (UnimplementedFrontendForQuerierHandler) QueryResult(context.Context, *connect.Request[frontendpb.QueryResultRequest]) (*connect.Response[frontendpb.QueryResultResponse], error) { 113 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("frontendpb.FrontendForQuerier.QueryResult is not implemented")) 114 }