Path: blob/main/components/supervisor-api/go/task.pb.gw.go
2498 views
// Copyright (c) 2024 Gitpod GmbH. All rights reserved.1// Licensed under the GNU Affero General Public License (AGPL).2// See License.AGPL.txt in the project root for license information.34// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.5// source: task.proto67/*8Package api is a reverse proxy.910It translates gRPC into RESTful JSON APIs.11*/12package api1314import (15"context"16"io"17"net/http"1819"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"20"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"21"google.golang.org/grpc"22"google.golang.org/grpc/codes"23"google.golang.org/grpc/grpclog"24"google.golang.org/grpc/metadata"25"google.golang.org/grpc/status"26"google.golang.org/protobuf/proto"27)2829// Suppress "imported and not used" errors30var _ codes.Code31var _ io.Reader32var _ status.Status33var _ = runtime.String34var _ = utilities.NewDoubleArray35var _ = metadata.Join3637func request_TaskService_ListenToOutput_0(ctx context.Context, marshaler runtime.Marshaler, client TaskServiceClient, req *http.Request, pathParams map[string]string) (TaskService_ListenToOutputClient, runtime.ServerMetadata, error) {38var protoReq ListenToOutputRequest39var metadata runtime.ServerMetadata4041var (42val string43ok bool44err error45_ = err46)4748val, ok = pathParams["task_id"]49if !ok {50return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "task_id")51}5253protoReq.TaskId, err = runtime.String(val)54if err != nil {55return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "task_id", err)56}5758stream, err := client.ListenToOutput(ctx, &protoReq)59if err != nil {60return nil, metadata, err61}62header, err := stream.Header()63if err != nil {64return nil, metadata, err65}66metadata.HeaderMD = header67return stream, metadata, nil6869}7071// RegisterTaskServiceHandlerServer registers the http handlers for service TaskService to "mux".72// UnaryRPC :call TaskServiceServer directly.73// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.74// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterTaskServiceHandlerFromEndpoint instead.75func RegisterTaskServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TaskServiceServer) error {7677mux.Handle("GET", pattern_TaskService_ListenToOutput_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {78err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport")79_, outboundMarshaler := runtime.MarshalerForRequest(mux, req)80runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)81return82})8384return nil85}8687// RegisterTaskServiceHandlerFromEndpoint is same as RegisterTaskServiceHandler but88// automatically dials to "endpoint" and closes the connection when "ctx" gets done.89func RegisterTaskServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {90conn, err := grpc.Dial(endpoint, opts...)91if err != nil {92return err93}94defer func() {95if err != nil {96if cerr := conn.Close(); cerr != nil {97grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)98}99return100}101go func() {102<-ctx.Done()103if cerr := conn.Close(); cerr != nil {104grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)105}106}()107}()108109return RegisterTaskServiceHandler(ctx, mux, conn)110}111112// RegisterTaskServiceHandler registers the http handlers for service TaskService to "mux".113// The handlers forward requests to the grpc endpoint over "conn".114func RegisterTaskServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {115return RegisterTaskServiceHandlerClient(ctx, mux, NewTaskServiceClient(conn))116}117118// RegisterTaskServiceHandlerClient registers the http handlers for service TaskService119// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "TaskServiceClient".120// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "TaskServiceClient"121// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in122// "TaskServiceClient" to call the correct interceptors.123func RegisterTaskServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TaskServiceClient) error {124125mux.Handle("GET", pattern_TaskService_ListenToOutput_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {126ctx, cancel := context.WithCancel(req.Context())127defer cancel()128inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)129var err error130var annotatedContext context.Context131annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/supervisor.TaskService/ListenToOutput", runtime.WithHTTPPathPattern("/v1/task/listen/{task_id}/output"))132if err != nil {133runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)134return135}136resp, md, err := request_TaskService_ListenToOutput_0(annotatedContext, inboundMarshaler, client, req, pathParams)137annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)138if err != nil {139runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)140return141}142143forward_TaskService_ListenToOutput_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)144145})146147return nil148}149150var (151pattern_TaskService_ListenToOutput_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"v1", "task", "listen", "task_id", "output"}, ""))152)153154var (155forward_TaskService_ListenToOutput_0 = runtime.ForwardResponseStream156)157158159