Debian Codegraph @

runner/v1/runnerv1connect/services.connect.go

raw symbols SCIP
1 // Code generated by protoc-gen-connect-go. DO NOT EDIT.
2 //
3 // Source: runner/v1/services.proto
4
5 package runnerv1connect
6
7 import (
8 connect "connectrpc.com/connect"
9 context "context"
10 errors "errors"
11 v1 "gitea.dev/actions-proto-go/runner/v1"
12 http "net/http"
13 strings "strings"
14 )
15
16 // This is a compile-time assertion to ensure that this generated file and the connect package are
17 // compatible. If you get a compiler error that this constant is not defined, this code was
18 // generated with a version of connect newer than the one compiled into your binary. You can fix the
19 // problem by either regenerating this code with an older version of connect or updating the connect
20 // version compiled into your binary.
21 const _ = connect.IsAtLeastVersion1_13_0
22
23 const (
24 // RunnerServiceName is the fully-qualified name of the RunnerService service.
25 RunnerServiceName = "runner.v1.RunnerService"
26 )
27
28 // These constants are the fully-qualified names of the RPCs defined in this package. They're
29 // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
30 //
31 // Note that these are different from the fully-qualified method names used by
32 // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
33 // reflection-formatted method names, remove the leading slash and convert the remaining slash to a
34 // period.
35 const (
36 // RunnerServiceRegisterProcedure is the fully-qualified name of the RunnerService's Register RPC.
37 RunnerServiceRegisterProcedure = "/runner.v1.RunnerService/Register"
38 // RunnerServiceDeclareProcedure is the fully-qualified name of the RunnerService's Declare RPC.
39 RunnerServiceDeclareProcedure = "/runner.v1.RunnerService/Declare"
40 // RunnerServiceFetchTaskProcedure is the fully-qualified name of the RunnerService's FetchTask RPC.
41 RunnerServiceFetchTaskProcedure = "/runner.v1.RunnerService/FetchTask"
42 // RunnerServiceUpdateTaskProcedure is the fully-qualified name of the RunnerService's UpdateTask
43 // RPC.
44 RunnerServiceUpdateTaskProcedure = "/runner.v1.RunnerService/UpdateTask"
45 // RunnerServiceUpdateLogProcedure is the fully-qualified name of the RunnerService's UpdateLog RPC.
46 RunnerServiceUpdateLogProcedure = "/runner.v1.RunnerService/UpdateLog"
47 )
48
49 // These variables are the protoreflect.Descriptor objects for the RPCs defined in this package.
50 var (
51 runnerServiceServiceDescriptor = v1.File_runner_v1_services_proto.Services().ByName("RunnerService")
52 runnerServiceRegisterMethodDescriptor = runnerServiceServiceDescriptor.Methods().ByName("Register")
53 runnerServiceDeclareMethodDescriptor = runnerServiceServiceDescriptor.Methods().ByName("Declare")
54 runnerServiceFetchTaskMethodDescriptor = runnerServiceServiceDescriptor.Methods().ByName("FetchTask")
55 runnerServiceUpdateTaskMethodDescriptor = runnerServiceServiceDescriptor.Methods().ByName("UpdateTask")
56 runnerServiceUpdateLogMethodDescriptor = runnerServiceServiceDescriptor.Methods().ByName("UpdateLog")
57 )
58
59 // RunnerServiceClient is a client for the runner.v1.RunnerService service.
60 type RunnerServiceClient interface {
61 // Register register a new runner in server.
62 Register(context.Context, *connect.Request[v1.RegisterRequest]) (*connect.Response[v1.RegisterResponse], error)
63 // Declare declare runner's version and labels to Gitea before starting fetching task.
64 Declare(context.Context, *connect.Request[v1.DeclareRequest]) (*connect.Response[v1.DeclareResponse], error)
65 // FetchTask requests the next available task for execution.
66 FetchTask(context.Context, *connect.Request[v1.FetchTaskRequest]) (*connect.Response[v1.FetchTaskResponse], error)
67 // UpdateTask updates the task status.
68 UpdateTask(context.Context, *connect.Request[v1.UpdateTaskRequest]) (*connect.Response[v1.UpdateTaskResponse], error)
69 // UpdateLog uploads log of the task.
70 UpdateLog(context.Context, *connect.Request[v1.UpdateLogRequest]) (*connect.Response[v1.UpdateLogResponse], error)
71 }
72
73 // NewRunnerServiceClient constructs a client for the runner.v1.RunnerService service. By default,
74 // it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and
75 // sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC()
76 // or connect.WithGRPCWeb() options.
77 //
78 // The URL supplied here should be the base URL for the Connect or gRPC server (for example,
79 // http://api.acme.com or https://acme.com/grpc).
80 func NewRunnerServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) RunnerServiceClient {
81 baseURL = strings.TrimRight(baseURL, "/")
82 return &runnerServiceClient{
83 register: connect.NewClient[v1.RegisterRequest, v1.RegisterResponse](
84 httpClient,
85 baseURL+RunnerServiceRegisterProcedure,
86 connect.WithSchema(runnerServiceRegisterMethodDescriptor),
87 connect.WithClientOptions(opts...),
88 ),
89 declare: connect.NewClient[v1.DeclareRequest, v1.DeclareResponse](
90 httpClient,
91 baseURL+RunnerServiceDeclareProcedure,
92 connect.WithSchema(runnerServiceDeclareMethodDescriptor),
93 connect.WithClientOptions(opts...),
94 ),
95 fetchTask: connect.NewClient[v1.FetchTaskRequest, v1.FetchTaskResponse](
96 httpClient,
97 baseURL+RunnerServiceFetchTaskProcedure,
98 connect.WithSchema(runnerServiceFetchTaskMethodDescriptor),
99 connect.WithClientOptions(opts...),
100 ),
101 updateTask: connect.NewClient[v1.UpdateTaskRequest, v1.UpdateTaskResponse](
102 httpClient,
103 baseURL+RunnerServiceUpdateTaskProcedure,
104 connect.WithSchema(runnerServiceUpdateTaskMethodDescriptor),
105 connect.WithClientOptions(opts...),
106 ),
107 updateLog: connect.NewClient[v1.UpdateLogRequest, v1.UpdateLogResponse](
108 httpClient,
109 baseURL+RunnerServiceUpdateLogProcedure,
110 connect.WithSchema(runnerServiceUpdateLogMethodDescriptor),
111 connect.WithClientOptions(opts...),
112 ),
113 }
114 }
115
116 // runnerServiceClient implements RunnerServiceClient.
117 type runnerServiceClient struct {
118 register *connect.Client[v1.RegisterRequest, v1.RegisterResponse]
119 declare *connect.Client[v1.DeclareRequest, v1.DeclareResponse]
120 fetchTask *connect.Client[v1.FetchTaskRequest, v1.FetchTaskResponse]
121 updateTask *connect.Client[v1.UpdateTaskRequest, v1.UpdateTaskResponse]
122 updateLog *connect.Client[v1.UpdateLogRequest, v1.UpdateLogResponse]
123 }
124
125 // Register calls runner.v1.RunnerService.Register.
126 func (c *runnerServiceClient) Register(ctx context.Context, req *connect.Request[v1.RegisterRequest]) (*connect.Response[v1.RegisterResponse], error) {
127 return c.register.CallUnary(ctx, req)
128 }
129
130 // Declare calls runner.v1.RunnerService.Declare.
131 func (c *runnerServiceClient) Declare(ctx context.Context, req *connect.Request[v1.DeclareRequest]) (*connect.Response[v1.DeclareResponse], error) {
132 return c.declare.CallUnary(ctx, req)
133 }
134
135 // FetchTask calls runner.v1.RunnerService.FetchTask.
136 func (c *runnerServiceClient) FetchTask(ctx context.Context, req *connect.Request[v1.FetchTaskRequest]) (*connect.Response[v1.FetchTaskResponse], error) {
137 return c.fetchTask.CallUnary(ctx, req)
138 }
139
140 // UpdateTask calls runner.v1.RunnerService.UpdateTask.
141 func (c *runnerServiceClient) UpdateTask(ctx context.Context, req *connect.Request[v1.UpdateTaskRequest]) (*connect.Response[v1.UpdateTaskResponse], error) {
142 return c.updateTask.CallUnary(ctx, req)
143 }
144
145 // UpdateLog calls runner.v1.RunnerService.UpdateLog.
146 func (c *runnerServiceClient) UpdateLog(ctx context.Context, req *connect.Request[v1.UpdateLogRequest]) (*connect.Response[v1.UpdateLogResponse], error) {
147 return c.updateLog.CallUnary(ctx, req)
148 }
149
150 // RunnerServiceHandler is an implementation of the runner.v1.RunnerService service.
151 type RunnerServiceHandler interface {
152 // Register register a new runner in server.
153 Register(context.Context, *connect.Request[v1.RegisterRequest]) (*connect.Response[v1.RegisterResponse], error)
154 // Declare declare runner's version and labels to Gitea before starting fetching task.
155 Declare(context.Context, *connect.Request[v1.DeclareRequest]) (*connect.Response[v1.DeclareResponse], error)
156 // FetchTask requests the next available task for execution.
157 FetchTask(context.Context, *connect.Request[v1.FetchTaskRequest]) (*connect.Response[v1.FetchTaskResponse], error)
158 // UpdateTask updates the task status.
159 UpdateTask(context.Context, *connect.Request[v1.UpdateTaskRequest]) (*connect.Response[v1.UpdateTaskResponse], error)
160 // UpdateLog uploads log of the task.
161 UpdateLog(context.Context, *connect.Request[v1.UpdateLogRequest]) (*connect.Response[v1.UpdateLogResponse], error)
162 }
163
164 // NewRunnerServiceHandler builds an HTTP handler from the service implementation. It returns the
165 // path on which to mount the handler and the handler itself.
166 //
167 // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
168 // and JSON codecs. They also support gzip compression.
169 func NewRunnerServiceHandler(svc RunnerServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
170 runnerServiceRegisterHandler := connect.NewUnaryHandler(
171 RunnerServiceRegisterProcedure,
172 svc.Register,
173 connect.WithSchema(runnerServiceRegisterMethodDescriptor),
174 connect.WithHandlerOptions(opts...),
175 )
176 runnerServiceDeclareHandler := connect.NewUnaryHandler(
177 RunnerServiceDeclareProcedure,
178 svc.Declare,
179 connect.WithSchema(runnerServiceDeclareMethodDescriptor),
180 connect.WithHandlerOptions(opts...),
181 )
182 runnerServiceFetchTaskHandler := connect.NewUnaryHandler(
183 RunnerServiceFetchTaskProcedure,
184 svc.FetchTask,
185 connect.WithSchema(runnerServiceFetchTaskMethodDescriptor),
186 connect.WithHandlerOptions(opts...),
187 )
188 runnerServiceUpdateTaskHandler := connect.NewUnaryHandler(
189 RunnerServiceUpdateTaskProcedure,
190 svc.UpdateTask,
191 connect.WithSchema(runnerServiceUpdateTaskMethodDescriptor),
192 connect.WithHandlerOptions(opts...),
193 )
194 runnerServiceUpdateLogHandler := connect.NewUnaryHandler(
195 RunnerServiceUpdateLogProcedure,
196 svc.UpdateLog,
197 connect.WithSchema(runnerServiceUpdateLogMethodDescriptor),
198 connect.WithHandlerOptions(opts...),
199 )
200 return "/runner.v1.RunnerService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
201 switch r.URL.Path {
202 case RunnerServiceRegisterProcedure:
203 runnerServiceRegisterHandler.ServeHTTP(w, r)
204 case RunnerServiceDeclareProcedure:
205 runnerServiceDeclareHandler.ServeHTTP(w, r)
206 case RunnerServiceFetchTaskProcedure:
207 runnerServiceFetchTaskHandler.ServeHTTP(w, r)
208 case RunnerServiceUpdateTaskProcedure:
209 runnerServiceUpdateTaskHandler.ServeHTTP(w, r)
210 case RunnerServiceUpdateLogProcedure:
211 runnerServiceUpdateLogHandler.ServeHTTP(w, r)
212 default:
213 http.NotFound(w, r)
214 }
215 })
216 }
217
218 // UnimplementedRunnerServiceHandler returns CodeUnimplemented from all methods.
219 type UnimplementedRunnerServiceHandler struct{}
220
221 func (UnimplementedRunnerServiceHandler) Register(context.Context, *connect.Request[v1.RegisterRequest]) (*connect.Response[v1.RegisterResponse], error) {
222 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("runner.v1.RunnerService.Register is not implemented"))
223 }
224
225 func (UnimplementedRunnerServiceHandler) Declare(context.Context, *connect.Request[v1.DeclareRequest]) (*connect.Response[v1.DeclareResponse], error) {
226 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("runner.v1.RunnerService.Declare is not implemented"))
227 }
228
229 func (UnimplementedRunnerServiceHandler) FetchTask(context.Context, *connect.Request[v1.FetchTaskRequest]) (*connect.Response[v1.FetchTaskResponse], error) {
230 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("runner.v1.RunnerService.FetchTask is not implemented"))
231 }
232
233 func (UnimplementedRunnerServiceHandler) UpdateTask(context.Context, *connect.Request[v1.UpdateTaskRequest]) (*connect.Response[v1.UpdateTaskResponse], error) {
234 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("runner.v1.RunnerService.UpdateTask is not implemented"))
235 }
236
237 func (UnimplementedRunnerServiceHandler) UpdateLog(context.Context, *connect.Request[v1.UpdateLogRequest]) (*connect.Response[v1.UpdateLogResponse], error) {
238 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("runner.v1.RunnerService.UpdateLog is not implemented"))
239 }