github.com/grafana/pyroscope@v1.18.0/pkg/scheduler/schedulerpb/schedulerpbconnect/scheduler.connect.go (about) 1 // SPDX-License-Identifier: AGPL-3.0-only 2 // Provenance-includes-location: https://github.com/cortexproject/cortex/blob/master/pkg/scheduler/schedulerpb/scheduler.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: scheduler/schedulerpb/scheduler.proto 9 10 package schedulerpbconnect 11 12 import ( 13 connect "connectrpc.com/connect" 14 context "context" 15 errors "errors" 16 schedulerpb "github.com/grafana/pyroscope/pkg/scheduler/schedulerpb" 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 // SchedulerForQuerierName is the fully-qualified name of the SchedulerForQuerier service. 30 SchedulerForQuerierName = "schedulerpb.SchedulerForQuerier" 31 // SchedulerForFrontendName is the fully-qualified name of the SchedulerForFrontend service. 32 SchedulerForFrontendName = "schedulerpb.SchedulerForFrontend" 33 ) 34 35 // These constants are the fully-qualified names of the RPCs defined in this package. They're 36 // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. 37 // 38 // Note that these are different from the fully-qualified method names used by 39 // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to 40 // reflection-formatted method names, remove the leading slash and convert the remaining slash to a 41 // period. 42 const ( 43 // SchedulerForQuerierQuerierLoopProcedure is the fully-qualified name of the SchedulerForQuerier's 44 // QuerierLoop RPC. 45 SchedulerForQuerierQuerierLoopProcedure = "/schedulerpb.SchedulerForQuerier/QuerierLoop" 46 // SchedulerForQuerierNotifyQuerierShutdownProcedure is the fully-qualified name of the 47 // SchedulerForQuerier's NotifyQuerierShutdown RPC. 48 SchedulerForQuerierNotifyQuerierShutdownProcedure = "/schedulerpb.SchedulerForQuerier/NotifyQuerierShutdown" 49 // SchedulerForFrontendFrontendLoopProcedure is the fully-qualified name of the 50 // SchedulerForFrontend's FrontendLoop RPC. 51 SchedulerForFrontendFrontendLoopProcedure = "/schedulerpb.SchedulerForFrontend/FrontendLoop" 52 ) 53 54 // SchedulerForQuerierClient is a client for the schedulerpb.SchedulerForQuerier service. 55 type SchedulerForQuerierClient interface { 56 // After calling this method, both Querier and Scheduler enter a loop, in which querier waits for 57 // "SchedulerToQuerier" messages containing HTTP requests and processes them. After processing the request, 58 // querier signals that it is ready to accept another one by sending empty QuerierToScheduler message. 59 // 60 // Long-running loop is used to detect broken connection between scheduler and querier. This is important 61 // for scheduler to keep a list of connected queriers up-to-date. 62 QuerierLoop(context.Context) *connect.BidiStreamForClient[schedulerpb.QuerierToScheduler, schedulerpb.SchedulerToQuerier] 63 // The querier notifies the query-scheduler that it started a graceful shutdown. 64 NotifyQuerierShutdown(context.Context, *connect.Request[schedulerpb.NotifyQuerierShutdownRequest]) (*connect.Response[schedulerpb.NotifyQuerierShutdownResponse], error) 65 } 66 67 // NewSchedulerForQuerierClient constructs a client for the schedulerpb.SchedulerForQuerier service. 68 // By default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped 69 // responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the 70 // connect.WithGRPC() or connect.WithGRPCWeb() options. 71 // 72 // The URL supplied here should be the base URL for the Connect or gRPC server (for example, 73 // http://api.acme.com or https://acme.com/grpc). 74 func NewSchedulerForQuerierClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SchedulerForQuerierClient { 75 baseURL = strings.TrimRight(baseURL, "/") 76 schedulerForQuerierMethods := schedulerpb.File_scheduler_schedulerpb_scheduler_proto.Services().ByName("SchedulerForQuerier").Methods() 77 return &schedulerForQuerierClient{ 78 querierLoop: connect.NewClient[schedulerpb.QuerierToScheduler, schedulerpb.SchedulerToQuerier]( 79 httpClient, 80 baseURL+SchedulerForQuerierQuerierLoopProcedure, 81 connect.WithSchema(schedulerForQuerierMethods.ByName("QuerierLoop")), 82 connect.WithClientOptions(opts...), 83 ), 84 notifyQuerierShutdown: connect.NewClient[schedulerpb.NotifyQuerierShutdownRequest, schedulerpb.NotifyQuerierShutdownResponse]( 85 httpClient, 86 baseURL+SchedulerForQuerierNotifyQuerierShutdownProcedure, 87 connect.WithSchema(schedulerForQuerierMethods.ByName("NotifyQuerierShutdown")), 88 connect.WithClientOptions(opts...), 89 ), 90 } 91 } 92 93 // schedulerForQuerierClient implements SchedulerForQuerierClient. 94 type schedulerForQuerierClient struct { 95 querierLoop *connect.Client[schedulerpb.QuerierToScheduler, schedulerpb.SchedulerToQuerier] 96 notifyQuerierShutdown *connect.Client[schedulerpb.NotifyQuerierShutdownRequest, schedulerpb.NotifyQuerierShutdownResponse] 97 } 98 99 // QuerierLoop calls schedulerpb.SchedulerForQuerier.QuerierLoop. 100 func (c *schedulerForQuerierClient) QuerierLoop(ctx context.Context) *connect.BidiStreamForClient[schedulerpb.QuerierToScheduler, schedulerpb.SchedulerToQuerier] { 101 return c.querierLoop.CallBidiStream(ctx) 102 } 103 104 // NotifyQuerierShutdown calls schedulerpb.SchedulerForQuerier.NotifyQuerierShutdown. 105 func (c *schedulerForQuerierClient) NotifyQuerierShutdown(ctx context.Context, req *connect.Request[schedulerpb.NotifyQuerierShutdownRequest]) (*connect.Response[schedulerpb.NotifyQuerierShutdownResponse], error) { 106 return c.notifyQuerierShutdown.CallUnary(ctx, req) 107 } 108 109 // SchedulerForQuerierHandler is an implementation of the schedulerpb.SchedulerForQuerier service. 110 type SchedulerForQuerierHandler interface { 111 // After calling this method, both Querier and Scheduler enter a loop, in which querier waits for 112 // "SchedulerToQuerier" messages containing HTTP requests and processes them. After processing the request, 113 // querier signals that it is ready to accept another one by sending empty QuerierToScheduler message. 114 // 115 // Long-running loop is used to detect broken connection between scheduler and querier. This is important 116 // for scheduler to keep a list of connected queriers up-to-date. 117 QuerierLoop(context.Context, *connect.BidiStream[schedulerpb.QuerierToScheduler, schedulerpb.SchedulerToQuerier]) error 118 // The querier notifies the query-scheduler that it started a graceful shutdown. 119 NotifyQuerierShutdown(context.Context, *connect.Request[schedulerpb.NotifyQuerierShutdownRequest]) (*connect.Response[schedulerpb.NotifyQuerierShutdownResponse], error) 120 } 121 122 // NewSchedulerForQuerierHandler builds an HTTP handler from the service implementation. It returns 123 // the path on which to mount the handler and the handler itself. 124 // 125 // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf 126 // and JSON codecs. They also support gzip compression. 127 func NewSchedulerForQuerierHandler(svc SchedulerForQuerierHandler, opts ...connect.HandlerOption) (string, http.Handler) { 128 schedulerForQuerierMethods := schedulerpb.File_scheduler_schedulerpb_scheduler_proto.Services().ByName("SchedulerForQuerier").Methods() 129 schedulerForQuerierQuerierLoopHandler := connect.NewBidiStreamHandler( 130 SchedulerForQuerierQuerierLoopProcedure, 131 svc.QuerierLoop, 132 connect.WithSchema(schedulerForQuerierMethods.ByName("QuerierLoop")), 133 connect.WithHandlerOptions(opts...), 134 ) 135 schedulerForQuerierNotifyQuerierShutdownHandler := connect.NewUnaryHandler( 136 SchedulerForQuerierNotifyQuerierShutdownProcedure, 137 svc.NotifyQuerierShutdown, 138 connect.WithSchema(schedulerForQuerierMethods.ByName("NotifyQuerierShutdown")), 139 connect.WithHandlerOptions(opts...), 140 ) 141 return "/schedulerpb.SchedulerForQuerier/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 142 switch r.URL.Path { 143 case SchedulerForQuerierQuerierLoopProcedure: 144 schedulerForQuerierQuerierLoopHandler.ServeHTTP(w, r) 145 case SchedulerForQuerierNotifyQuerierShutdownProcedure: 146 schedulerForQuerierNotifyQuerierShutdownHandler.ServeHTTP(w, r) 147 default: 148 http.NotFound(w, r) 149 } 150 }) 151 } 152 153 // UnimplementedSchedulerForQuerierHandler returns CodeUnimplemented from all methods. 154 type UnimplementedSchedulerForQuerierHandler struct{} 155 156 func (UnimplementedSchedulerForQuerierHandler) QuerierLoop(context.Context, *connect.BidiStream[schedulerpb.QuerierToScheduler, schedulerpb.SchedulerToQuerier]) error { 157 return connect.NewError(connect.CodeUnimplemented, errors.New("schedulerpb.SchedulerForQuerier.QuerierLoop is not implemented")) 158 } 159 160 func (UnimplementedSchedulerForQuerierHandler) NotifyQuerierShutdown(context.Context, *connect.Request[schedulerpb.NotifyQuerierShutdownRequest]) (*connect.Response[schedulerpb.NotifyQuerierShutdownResponse], error) { 161 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("schedulerpb.SchedulerForQuerier.NotifyQuerierShutdown is not implemented")) 162 } 163 164 // SchedulerForFrontendClient is a client for the schedulerpb.SchedulerForFrontend service. 165 type SchedulerForFrontendClient interface { 166 // After calling this method, both Frontend and Scheduler enter a loop. Frontend will keep sending ENQUEUE and 167 // CANCEL requests, and scheduler is expected to process them. Scheduler returns one response for each request. 168 // 169 // Long-running loop is used to detect broken connection between frontend and scheduler. This is important for both 170 // parties... if connection breaks, frontend can cancel (and possibly retry on different scheduler) all pending 171 // requests sent to this scheduler, while scheduler can cancel queued requests from given frontend. 172 FrontendLoop(context.Context) *connect.BidiStreamForClient[schedulerpb.FrontendToScheduler, schedulerpb.SchedulerToFrontend] 173 } 174 175 // NewSchedulerForFrontendClient constructs a client for the schedulerpb.SchedulerForFrontend 176 // service. By default, it uses the Connect protocol with the binary Protobuf Codec, asks for 177 // gzipped responses, and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply 178 // the connect.WithGRPC() or connect.WithGRPCWeb() options. 179 // 180 // The URL supplied here should be the base URL for the Connect or gRPC server (for example, 181 // http://api.acme.com or https://acme.com/grpc). 182 func NewSchedulerForFrontendClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) SchedulerForFrontendClient { 183 baseURL = strings.TrimRight(baseURL, "/") 184 schedulerForFrontendMethods := schedulerpb.File_scheduler_schedulerpb_scheduler_proto.Services().ByName("SchedulerForFrontend").Methods() 185 return &schedulerForFrontendClient{ 186 frontendLoop: connect.NewClient[schedulerpb.FrontendToScheduler, schedulerpb.SchedulerToFrontend]( 187 httpClient, 188 baseURL+SchedulerForFrontendFrontendLoopProcedure, 189 connect.WithSchema(schedulerForFrontendMethods.ByName("FrontendLoop")), 190 connect.WithClientOptions(opts...), 191 ), 192 } 193 } 194 195 // schedulerForFrontendClient implements SchedulerForFrontendClient. 196 type schedulerForFrontendClient struct { 197 frontendLoop *connect.Client[schedulerpb.FrontendToScheduler, schedulerpb.SchedulerToFrontend] 198 } 199 200 // FrontendLoop calls schedulerpb.SchedulerForFrontend.FrontendLoop. 201 func (c *schedulerForFrontendClient) FrontendLoop(ctx context.Context) *connect.BidiStreamForClient[schedulerpb.FrontendToScheduler, schedulerpb.SchedulerToFrontend] { 202 return c.frontendLoop.CallBidiStream(ctx) 203 } 204 205 // SchedulerForFrontendHandler is an implementation of the schedulerpb.SchedulerForFrontend service. 206 type SchedulerForFrontendHandler interface { 207 // After calling this method, both Frontend and Scheduler enter a loop. Frontend will keep sending ENQUEUE and 208 // CANCEL requests, and scheduler is expected to process them. Scheduler returns one response for each request. 209 // 210 // Long-running loop is used to detect broken connection between frontend and scheduler. This is important for both 211 // parties... if connection breaks, frontend can cancel (and possibly retry on different scheduler) all pending 212 // requests sent to this scheduler, while scheduler can cancel queued requests from given frontend. 213 FrontendLoop(context.Context, *connect.BidiStream[schedulerpb.FrontendToScheduler, schedulerpb.SchedulerToFrontend]) error 214 } 215 216 // NewSchedulerForFrontendHandler builds an HTTP handler from the service implementation. It returns 217 // the path on which to mount the handler and the handler itself. 218 // 219 // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf 220 // and JSON codecs. They also support gzip compression. 221 func NewSchedulerForFrontendHandler(svc SchedulerForFrontendHandler, opts ...connect.HandlerOption) (string, http.Handler) { 222 schedulerForFrontendMethods := schedulerpb.File_scheduler_schedulerpb_scheduler_proto.Services().ByName("SchedulerForFrontend").Methods() 223 schedulerForFrontendFrontendLoopHandler := connect.NewBidiStreamHandler( 224 SchedulerForFrontendFrontendLoopProcedure, 225 svc.FrontendLoop, 226 connect.WithSchema(schedulerForFrontendMethods.ByName("FrontendLoop")), 227 connect.WithHandlerOptions(opts...), 228 ) 229 return "/schedulerpb.SchedulerForFrontend/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 230 switch r.URL.Path { 231 case SchedulerForFrontendFrontendLoopProcedure: 232 schedulerForFrontendFrontendLoopHandler.ServeHTTP(w, r) 233 default: 234 http.NotFound(w, r) 235 } 236 }) 237 } 238 239 // UnimplementedSchedulerForFrontendHandler returns CodeUnimplemented from all methods. 240 type UnimplementedSchedulerForFrontendHandler struct{} 241 242 func (UnimplementedSchedulerForFrontendHandler) FrontendLoop(context.Context, *connect.BidiStream[schedulerpb.FrontendToScheduler, schedulerpb.SchedulerToFrontend]) error { 243 return connect.NewError(connect.CodeUnimplemented, errors.New("schedulerpb.SchedulerForFrontend.FrontendLoop is not implemented")) 244 }