1// SPDX-License-Identifier: MIT
2
3// Code generated by protoc-gen-connect-go. DO NOT EDIT.
4//
5// Source: ermite/git.proto
6
7package ermiteconnect
8
9import (
10 ermite "bnema.dev/ermite-api/gen/ermite"
11 connect "connectrpc.com/connect"
12 context "context"
13 errors "errors"
14 http "net/http"
15 strings "strings"
16)
17
18// This is a compile-time assertion to ensure that this generated file and the connect package are
19// compatible. If you get a compiler error that this constant is not defined, this code was
20// generated with a version of connect newer than the one compiled into your binary. You can fix the
21// problem by either regenerating this code with an older version of connect or updating the connect
22// version compiled into your binary.
23const _ = connect.IsAtLeastVersion1_13_0
24
25const (
26 // GitServiceName is the fully-qualified name of the GitService service.
27 GitServiceName = "ermite.GitService"
28)
29
30// These constants are the fully-qualified names of the RPCs defined in this package. They're
31// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
32//
33// Note that these are different from the fully-qualified method names used by
34// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
35// reflection-formatted method names, remove the leading slash and convert the remaining slash to a
36// period.
37const (
38 // GitServiceListRefsProcedure is the fully-qualified name of the GitService's ListRefs RPC.
39 GitServiceListRefsProcedure = "/ermite.GitService/ListRefs"
40 // GitServiceGetTreeProcedure is the fully-qualified name of the GitService's GetTree RPC.
41 GitServiceGetTreeProcedure = "/ermite.GitService/GetTree"
42 // GitServiceListPathsProcedure is the fully-qualified name of the GitService's ListPaths RPC.
43 GitServiceListPathsProcedure = "/ermite.GitService/ListPaths"
44 // GitServiceGetBlobProcedure is the fully-qualified name of the GitService's GetBlob RPC.
45 GitServiceGetBlobProcedure = "/ermite.GitService/GetBlob"
46 // GitServiceListCommitsProcedure is the fully-qualified name of the GitService's ListCommits RPC.
47 GitServiceListCommitsProcedure = "/ermite.GitService/ListCommits"
48 // GitServiceGetCommitProcedure is the fully-qualified name of the GitService's GetCommit RPC.
49 GitServiceGetCommitProcedure = "/ermite.GitService/GetCommit"
50 // GitServiceResolveRevisionProcedure is the fully-qualified name of the GitService's
51 // ResolveRevision RPC.
52 GitServiceResolveRevisionProcedure = "/ermite.GitService/ResolveRevision"
53)
54
55// GitServiceClient is a client for the ermite.GitService service.
56type GitServiceClient interface {
57 // ListRefs lists the branches, tags and HEAD of a repository. Refs are
58 // ordered by kind (HEAD, branches, tags) then by name.
59 ListRefs(context.Context, *connect.Request[ermite.ListRefsRequest]) (*connect.Response[ermite.ListRefsResponse], error)
60 // GetTree lists the entries of a directory at a revision. Fails with
61 // not_found if the path does not exist and invalid_argument if it is not a
62 // directory.
63 GetTree(context.Context, *connect.Request[ermite.GetTreeRequest]) (*connect.Response[ermite.GetTreeResponse], error)
64 // ListPaths lists the paths of every file and symbolic link of a revision,
65 // recursively, in Git tree order (the order of `git ls-tree -r`). Directories
66 // and submodules are not listed, nor paths GetBlob cannot address (not valid
67 // UTF-8, or with a control character). Fails with not_found for an unknown
68 // revision or an empty repository. Servers that have it advertise the
69 // feature "git.list_paths" in GetVersion.
70 ListPaths(context.Context, *connect.Request[ermite.ListPathsRequest]) (*connect.Response[ermite.ListPathsResponse], error)
71 // GetBlob streams the content of a file at a revision, in chunks of at most
72 // 64 KiB. The first message carries the metadata in info, then the chunks
73 // follow; the memory used by the server does not depend on the file size.
74 // Fails with not_found if the path does not exist and invalid_argument if it
75 // is not a file.
76 GetBlob(context.Context, *connect.Request[ermite.GetBlobRequest]) (*connect.ServerStreamForClient[ermite.GetBlobResponse], error)
77 // ListCommits lists the history reachable from a revision, newest first
78 // (Git's default order), optionally limited to the commits that touched a
79 // path. A page_token that points deeper than 100,000 commits into the
80 // history is invalid_argument.
81 ListCommits(context.Context, *connect.Request[ermite.ListCommitsRequest]) (*connect.Response[ermite.ListCommitsResponse], error)
82 // GetCommit returns one commit with its statistics and its diff.
83 GetCommit(context.Context, *connect.Request[ermite.GetCommitRequest]) (*connect.Response[ermite.GetCommitResponse], error)
84 // ResolveRevision turns a revision into the id of the commit it designates.
85 ResolveRevision(context.Context, *connect.Request[ermite.ResolveRevisionRequest]) (*connect.Response[ermite.ResolveRevisionResponse], error)
86}
87
88// NewGitServiceClient constructs a client for the ermite.GitService service. By default, it uses
89// the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
90// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
91// connect.WithGRPCWeb() options.
92//
93// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
94// http://api.acme.com or https://acme.com/grpc).
95func NewGitServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) GitServiceClient {
96 baseURL = strings.TrimRight(baseURL, "/")
97 gitServiceMethods := ermite.File_ermite_git_proto.Services().ByName("GitService").Methods()
98 return &gitServiceClient{
99 listRefs: connect.NewClient[ermite.ListRefsRequest, ermite.ListRefsResponse](
100 httpClient,
101 baseURL+GitServiceListRefsProcedure,
102 connect.WithSchema(gitServiceMethods.ByName("ListRefs")),
103 connect.WithClientOptions(opts...),
104 ),
105 getTree: connect.NewClient[ermite.GetTreeRequest, ermite.GetTreeResponse](
106 httpClient,
107 baseURL+GitServiceGetTreeProcedure,
108 connect.WithSchema(gitServiceMethods.ByName("GetTree")),
109 connect.WithClientOptions(opts...),
110 ),
111 listPaths: connect.NewClient[ermite.ListPathsRequest, ermite.ListPathsResponse](
112 httpClient,
113 baseURL+GitServiceListPathsProcedure,
114 connect.WithSchema(gitServiceMethods.ByName("ListPaths")),
115 connect.WithClientOptions(opts...),
116 ),
117 getBlob: connect.NewClient[ermite.GetBlobRequest, ermite.GetBlobResponse](
118 httpClient,
119 baseURL+GitServiceGetBlobProcedure,
120 connect.WithSchema(gitServiceMethods.ByName("GetBlob")),
121 connect.WithClientOptions(opts...),
122 ),
123 listCommits: connect.NewClient[ermite.ListCommitsRequest, ermite.ListCommitsResponse](
124 httpClient,
125 baseURL+GitServiceListCommitsProcedure,
126 connect.WithSchema(gitServiceMethods.ByName("ListCommits")),
127 connect.WithClientOptions(opts...),
128 ),
129 getCommit: connect.NewClient[ermite.GetCommitRequest, ermite.GetCommitResponse](
130 httpClient,
131 baseURL+GitServiceGetCommitProcedure,
132 connect.WithSchema(gitServiceMethods.ByName("GetCommit")),
133 connect.WithClientOptions(opts...),
134 ),
135 resolveRevision: connect.NewClient[ermite.ResolveRevisionRequest, ermite.ResolveRevisionResponse](
136 httpClient,
137 baseURL+GitServiceResolveRevisionProcedure,
138 connect.WithSchema(gitServiceMethods.ByName("ResolveRevision")),
139 connect.WithClientOptions(opts...),
140 ),
141 }
142}
143
144// gitServiceClient implements GitServiceClient.
145type gitServiceClient struct {
146 listRefs *connect.Client[ermite.ListRefsRequest, ermite.ListRefsResponse]
147 getTree *connect.Client[ermite.GetTreeRequest, ermite.GetTreeResponse]
148 listPaths *connect.Client[ermite.ListPathsRequest, ermite.ListPathsResponse]
149 getBlob *connect.Client[ermite.GetBlobRequest, ermite.GetBlobResponse]
150 listCommits *connect.Client[ermite.ListCommitsRequest, ermite.ListCommitsResponse]
151 getCommit *connect.Client[ermite.GetCommitRequest, ermite.GetCommitResponse]
152 resolveRevision *connect.Client[ermite.ResolveRevisionRequest, ermite.ResolveRevisionResponse]
153}
154
155// ListRefs calls ermite.GitService.ListRefs.
156func (c *gitServiceClient) ListRefs(ctx context.Context, req *connect.Request[ermite.ListRefsRequest]) (*connect.Response[ermite.ListRefsResponse], error) {
157 return c.listRefs.CallUnary(ctx, req)
158}
159
160// GetTree calls ermite.GitService.GetTree.
161func (c *gitServiceClient) GetTree(ctx context.Context, req *connect.Request[ermite.GetTreeRequest]) (*connect.Response[ermite.GetTreeResponse], error) {
162 return c.getTree.CallUnary(ctx, req)
163}
164
165// ListPaths calls ermite.GitService.ListPaths.
166func (c *gitServiceClient) ListPaths(ctx context.Context, req *connect.Request[ermite.ListPathsRequest]) (*connect.Response[ermite.ListPathsResponse], error) {
167 return c.listPaths.CallUnary(ctx, req)
168}
169
170// GetBlob calls ermite.GitService.GetBlob.
171func (c *gitServiceClient) GetBlob(ctx context.Context, req *connect.Request[ermite.GetBlobRequest]) (*connect.ServerStreamForClient[ermite.GetBlobResponse], error) {
172 return c.getBlob.CallServerStream(ctx, req)
173}
174
175// ListCommits calls ermite.GitService.ListCommits.
176func (c *gitServiceClient) ListCommits(ctx context.Context, req *connect.Request[ermite.ListCommitsRequest]) (*connect.Response[ermite.ListCommitsResponse], error) {
177 return c.listCommits.CallUnary(ctx, req)
178}
179
180// GetCommit calls ermite.GitService.GetCommit.
181func (c *gitServiceClient) GetCommit(ctx context.Context, req *connect.Request[ermite.GetCommitRequest]) (*connect.Response[ermite.GetCommitResponse], error) {
182 return c.getCommit.CallUnary(ctx, req)
183}
184
185// ResolveRevision calls ermite.GitService.ResolveRevision.
186func (c *gitServiceClient) ResolveRevision(ctx context.Context, req *connect.Request[ermite.ResolveRevisionRequest]) (*connect.Response[ermite.ResolveRevisionResponse], error) {
187 return c.resolveRevision.CallUnary(ctx, req)
188}
189
190// GitServiceHandler is an implementation of the ermite.GitService service.
191type GitServiceHandler interface {
192 // ListRefs lists the branches, tags and HEAD of a repository. Refs are
193 // ordered by kind (HEAD, branches, tags) then by name.
194 ListRefs(context.Context, *connect.Request[ermite.ListRefsRequest]) (*connect.Response[ermite.ListRefsResponse], error)
195 // GetTree lists the entries of a directory at a revision. Fails with
196 // not_found if the path does not exist and invalid_argument if it is not a
197 // directory.
198 GetTree(context.Context, *connect.Request[ermite.GetTreeRequest]) (*connect.Response[ermite.GetTreeResponse], error)
199 // ListPaths lists the paths of every file and symbolic link of a revision,
200 // recursively, in Git tree order (the order of `git ls-tree -r`). Directories
201 // and submodules are not listed, nor paths GetBlob cannot address (not valid
202 // UTF-8, or with a control character). Fails with not_found for an unknown
203 // revision or an empty repository. Servers that have it advertise the
204 // feature "git.list_paths" in GetVersion.
205 ListPaths(context.Context, *connect.Request[ermite.ListPathsRequest]) (*connect.Response[ermite.ListPathsResponse], error)
206 // GetBlob streams the content of a file at a revision, in chunks of at most
207 // 64 KiB. The first message carries the metadata in info, then the chunks
208 // follow; the memory used by the server does not depend on the file size.
209 // Fails with not_found if the path does not exist and invalid_argument if it
210 // is not a file.
211 GetBlob(context.Context, *connect.Request[ermite.GetBlobRequest], *connect.ServerStream[ermite.GetBlobResponse]) error
212 // ListCommits lists the history reachable from a revision, newest first
213 // (Git's default order), optionally limited to the commits that touched a
214 // path. A page_token that points deeper than 100,000 commits into the
215 // history is invalid_argument.
216 ListCommits(context.Context, *connect.Request[ermite.ListCommitsRequest]) (*connect.Response[ermite.ListCommitsResponse], error)
217 // GetCommit returns one commit with its statistics and its diff.
218 GetCommit(context.Context, *connect.Request[ermite.GetCommitRequest]) (*connect.Response[ermite.GetCommitResponse], error)
219 // ResolveRevision turns a revision into the id of the commit it designates.
220 ResolveRevision(context.Context, *connect.Request[ermite.ResolveRevisionRequest]) (*connect.Response[ermite.ResolveRevisionResponse], error)
221}
222
223// NewGitServiceHandler builds an HTTP handler from the service implementation. It returns the path
224// on which to mount the handler and the handler itself.
225//
226// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
227// and JSON codecs. They also support gzip compression.
228func NewGitServiceHandler(svc GitServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
229 gitServiceMethods := ermite.File_ermite_git_proto.Services().ByName("GitService").Methods()
230 gitServiceListRefsHandler := connect.NewUnaryHandler(
231 GitServiceListRefsProcedure,
232 svc.ListRefs,
233 connect.WithSchema(gitServiceMethods.ByName("ListRefs")),
234 connect.WithHandlerOptions(opts...),
235 )
236 gitServiceGetTreeHandler := connect.NewUnaryHandler(
237 GitServiceGetTreeProcedure,
238 svc.GetTree,
239 connect.WithSchema(gitServiceMethods.ByName("GetTree")),
240 connect.WithHandlerOptions(opts...),
241 )
242 gitServiceListPathsHandler := connect.NewUnaryHandler(
243 GitServiceListPathsProcedure,
244 svc.ListPaths,
245 connect.WithSchema(gitServiceMethods.ByName("ListPaths")),
246 connect.WithHandlerOptions(opts...),
247 )
248 gitServiceGetBlobHandler := connect.NewServerStreamHandler(
249 GitServiceGetBlobProcedure,
250 svc.GetBlob,
251 connect.WithSchema(gitServiceMethods.ByName("GetBlob")),
252 connect.WithHandlerOptions(opts...),
253 )
254 gitServiceListCommitsHandler := connect.NewUnaryHandler(
255 GitServiceListCommitsProcedure,
256 svc.ListCommits,
257 connect.WithSchema(gitServiceMethods.ByName("ListCommits")),
258 connect.WithHandlerOptions(opts...),
259 )
260 gitServiceGetCommitHandler := connect.NewUnaryHandler(
261 GitServiceGetCommitProcedure,
262 svc.GetCommit,
263 connect.WithSchema(gitServiceMethods.ByName("GetCommit")),
264 connect.WithHandlerOptions(opts...),
265 )
266 gitServiceResolveRevisionHandler := connect.NewUnaryHandler(
267 GitServiceResolveRevisionProcedure,
268 svc.ResolveRevision,
269 connect.WithSchema(gitServiceMethods.ByName("ResolveRevision")),
270 connect.WithHandlerOptions(opts...),
271 )
272 return "/ermite.GitService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
273 switch r.URL.Path {
274 case GitServiceListRefsProcedure:
275 gitServiceListRefsHandler.ServeHTTP(w, r)
276 case GitServiceGetTreeProcedure:
277 gitServiceGetTreeHandler.ServeHTTP(w, r)
278 case GitServiceListPathsProcedure:
279 gitServiceListPathsHandler.ServeHTTP(w, r)
280 case GitServiceGetBlobProcedure:
281 gitServiceGetBlobHandler.ServeHTTP(w, r)
282 case GitServiceListCommitsProcedure:
283 gitServiceListCommitsHandler.ServeHTTP(w, r)
284 case GitServiceGetCommitProcedure:
285 gitServiceGetCommitHandler.ServeHTTP(w, r)
286 case GitServiceResolveRevisionProcedure:
287 gitServiceResolveRevisionHandler.ServeHTTP(w, r)
288 default:
289 http.NotFound(w, r)
290 }
291 })
292}
293
294// UnimplementedGitServiceHandler returns CodeUnimplemented from all methods.
295type UnimplementedGitServiceHandler struct{}
296
297func (UnimplementedGitServiceHandler) ListRefs(context.Context, *connect.Request[ermite.ListRefsRequest]) (*connect.Response[ermite.ListRefsResponse], error) {
298 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.GitService.ListRefs is not implemented"))
299}
300
301func (UnimplementedGitServiceHandler) GetTree(context.Context, *connect.Request[ermite.GetTreeRequest]) (*connect.Response[ermite.GetTreeResponse], error) {
302 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.GitService.GetTree is not implemented"))
303}
304
305func (UnimplementedGitServiceHandler) ListPaths(context.Context, *connect.Request[ermite.ListPathsRequest]) (*connect.Response[ermite.ListPathsResponse], error) {
306 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.GitService.ListPaths is not implemented"))
307}
308
309func (UnimplementedGitServiceHandler) GetBlob(context.Context, *connect.Request[ermite.GetBlobRequest], *connect.ServerStream[ermite.GetBlobResponse]) error {
310 return connect.NewError(connect.CodeUnimplemented, errors.New("ermite.GitService.GetBlob is not implemented"))
311}
312
313func (UnimplementedGitServiceHandler) ListCommits(context.Context, *connect.Request[ermite.ListCommitsRequest]) (*connect.Response[ermite.ListCommitsResponse], error) {
314 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.GitService.ListCommits is not implemented"))
315}
316
317func (UnimplementedGitServiceHandler) GetCommit(context.Context, *connect.Request[ermite.GetCommitRequest]) (*connect.Response[ermite.GetCommitResponse], error) {
318 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.GitService.GetCommit is not implemented"))
319}
320
321func (UnimplementedGitServiceHandler) ResolveRevision(context.Context, *connect.Request[ermite.ResolveRevisionRequest]) (*connect.Response[ermite.ResolveRevisionResponse], error) {
322 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ermite.GitService.ResolveRevision is not implemented"))
323}