Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/supervisor-api/go/task.pb.gw.go
2498 views
1
// Copyright (c) 2024 Gitpod GmbH. All rights reserved.
2
// Licensed under the GNU Affero General Public License (AGPL).
3
// See License.AGPL.txt in the project root for license information.
4
5
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
6
// source: task.proto
7
8
/*
9
Package api is a reverse proxy.
10
11
It translates gRPC into RESTful JSON APIs.
12
*/
13
package api
14
15
import (
16
"context"
17
"io"
18
"net/http"
19
20
"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
21
"github.com/grpc-ecosystem/grpc-gateway/v2/utilities"
22
"google.golang.org/grpc"
23
"google.golang.org/grpc/codes"
24
"google.golang.org/grpc/grpclog"
25
"google.golang.org/grpc/metadata"
26
"google.golang.org/grpc/status"
27
"google.golang.org/protobuf/proto"
28
)
29
30
// Suppress "imported and not used" errors
31
var _ codes.Code
32
var _ io.Reader
33
var _ status.Status
34
var _ = runtime.String
35
var _ = utilities.NewDoubleArray
36
var _ = metadata.Join
37
38
func request_TaskService_ListenToOutput_0(ctx context.Context, marshaler runtime.Marshaler, client TaskServiceClient, req *http.Request, pathParams map[string]string) (TaskService_ListenToOutputClient, runtime.ServerMetadata, error) {
39
var protoReq ListenToOutputRequest
40
var metadata runtime.ServerMetadata
41
42
var (
43
val string
44
ok bool
45
err error
46
_ = err
47
)
48
49
val, ok = pathParams["task_id"]
50
if !ok {
51
return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "task_id")
52
}
53
54
protoReq.TaskId, err = runtime.String(val)
55
if err != nil {
56
return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "task_id", err)
57
}
58
59
stream, err := client.ListenToOutput(ctx, &protoReq)
60
if err != nil {
61
return nil, metadata, err
62
}
63
header, err := stream.Header()
64
if err != nil {
65
return nil, metadata, err
66
}
67
metadata.HeaderMD = header
68
return stream, metadata, nil
69
70
}
71
72
// RegisterTaskServiceHandlerServer registers the http handlers for service TaskService to "mux".
73
// UnaryRPC :call TaskServiceServer directly.
74
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
75
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterTaskServiceHandlerFromEndpoint instead.
76
func RegisterTaskServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server TaskServiceServer) error {
77
78
mux.Handle("GET", pattern_TaskService_ListenToOutput_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
79
err := status.Error(codes.Unimplemented, "streaming calls are not yet supported in the in-process transport")
80
_, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
81
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
82
return
83
})
84
85
return nil
86
}
87
88
// RegisterTaskServiceHandlerFromEndpoint is same as RegisterTaskServiceHandler but
89
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
90
func RegisterTaskServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
91
conn, err := grpc.Dial(endpoint, opts...)
92
if err != nil {
93
return err
94
}
95
defer func() {
96
if err != nil {
97
if cerr := conn.Close(); cerr != nil {
98
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
99
}
100
return
101
}
102
go func() {
103
<-ctx.Done()
104
if cerr := conn.Close(); cerr != nil {
105
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
106
}
107
}()
108
}()
109
110
return RegisterTaskServiceHandler(ctx, mux, conn)
111
}
112
113
// RegisterTaskServiceHandler registers the http handlers for service TaskService to "mux".
114
// The handlers forward requests to the grpc endpoint over "conn".
115
func RegisterTaskServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
116
return RegisterTaskServiceHandlerClient(ctx, mux, NewTaskServiceClient(conn))
117
}
118
119
// RegisterTaskServiceHandlerClient registers the http handlers for service TaskService
120
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "TaskServiceClient".
121
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "TaskServiceClient"
122
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
123
// "TaskServiceClient" to call the correct interceptors.
124
func RegisterTaskServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client TaskServiceClient) error {
125
126
mux.Handle("GET", pattern_TaskService_ListenToOutput_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
127
ctx, cancel := context.WithCancel(req.Context())
128
defer cancel()
129
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
130
var err error
131
var annotatedContext context.Context
132
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/supervisor.TaskService/ListenToOutput", runtime.WithHTTPPathPattern("/v1/task/listen/{task_id}/output"))
133
if err != nil {
134
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
135
return
136
}
137
resp, md, err := request_TaskService_ListenToOutput_0(annotatedContext, inboundMarshaler, client, req, pathParams)
138
annotatedContext = runtime.NewServerMetadataContext(annotatedContext, md)
139
if err != nil {
140
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
141
return
142
}
143
144
forward_TaskService_ListenToOutput_0(annotatedContext, mux, outboundMarshaler, w, req, func() (proto.Message, error) { return resp.Recv() }, mux.GetForwardResponseOptions()...)
145
146
})
147
148
return nil
149
}
150
151
var (
152
pattern_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"}, ""))
153
)
154
155
var (
156
forward_TaskService_ListenToOutput_0 = runtime.ForwardResponseStream
157
)
158
159