1// SPDX-License-Identifier: MIT
2
3// Code generated by protoc-gen-connect-go. DO NOT EDIT.
4//
5// Source: ermite/event.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 // EventServiceName is the fully-qualified name of the EventService service.
27 EventServiceName = "ermite.EventService"
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 // EventServiceWatchProcedure is the fully-qualified name of the EventService's Watch RPC.
39 EventServiceWatchProcedure = "/ermite.EventService/Watch"
40)
41
42// EventServiceClient is a client for the ermite.EventService service.
43type EventServiceClient interface {
44 // Watch streams events until the client cancels the call or the server shuts
45 // down. Events are filtered by the caller's access: events of a private
46 // repository are only sent to callers that may read it.
47 //
48 // The events are repo_created, repo_updated, repo_deleted, pushed, gap and,
49 // for merge requests, merge_request_opened, merge_request_merged,
50 // merge_request_closed, comment_added, comment_edited, comment_deleted and
51 // comment_resolved (a thread resolved or reopened); for issues, issue_opened,
52 // issue_closed, issue_resolved, issue_reopened and issue_commented, and
53 // issue_submitted. Each one is delivered on the "repo:<name>" topic of its
54 // repository and on "home", subject to the visibility of the repository,
55 // except
56 // issue_submitted: it is delivered only on the "owner" topic, never on
57 // "home" or "repo:<name>", and carries no content (see IssueSubmitted).
58 //
59 // Servers with the feature "ci.runs" also publish run_updated and
60 // job_updated, only on the "repo:<name>" topic of their repository (never on
61 // "home"), subject to the same visibility. They carry the state after the
62 // change and are published when a run or a job is created, changes status
63 // or conclusion, or when one of its steps starts or ends (never per log
64 // line: follow a log with RunService.GetJobLog). The order of these events
65 // is not guaranteed, between jobs and runs or between two updates of the same
66 // one: a client keeps the copy with the higher Run.version or
67 // RunJob.version and drops the other. There is no event for a change of title or
68 // description: after a gap, or to see such changes, clients read the merge
69 // request again. A merge publishes
70 // merge_request_merged, then pushed for the target branch.
71 //
72 // The server keeps a bounded buffer of recent events. With resume_after set,
73 // buffered events after that id are replayed first, then live events follow.
74 // When resume_after is no longer buffered (or unknown), the stream begins
75 // with a Gap event, then continues with the oldest buffered event: the client
76 // must reload its state. Without resume_after, only new events are sent.
77 //
78 // The access of the caller is checked again for every event: the stream ends
79 // with unauthenticated when the token was revoked or has expired (the server
80 // may take a few seconds to notice). A repository that becomes private
81 // sends one last repo_updated to the callers who could read it before, with
82 // the new visibility and nothing else about it; no later event of it
83 // reaches them. The server limits the watchers: more than 64 topics is
84 // invalid_argument, and too many concurrent streams, in total or from one
85 // client, is resource_exhausted.
86 Watch(context.Context, *connect.Request[ermite.WatchRequest]) (*connect.ServerStreamForClient[ermite.WatchResponse], error)
87}
88
89// NewEventServiceClient constructs a client for the ermite.EventService service. By default, it
90// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
91// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
92// connect.WithGRPCWeb() options.
93//
94// The URL supplied here should be the base URL for the Connect or gRPC server (for example,
95// http://api.acme.com or https://acme.com/grpc).
96func NewEventServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) EventServiceClient {
97 baseURL = strings.TrimRight(baseURL, "/")
98 eventServiceMethods := ermite.File_ermite_event_proto.Services().ByName("EventService").Methods()
99 return &eventServiceClient{
100 watch: connect.NewClient[ermite.WatchRequest, ermite.WatchResponse](
101 httpClient,
102 baseURL+EventServiceWatchProcedure,
103 connect.WithSchema(eventServiceMethods.ByName("Watch")),
104 connect.WithClientOptions(opts...),
105 ),
106 }
107}
108
109// eventServiceClient implements EventServiceClient.
110type eventServiceClient struct {
111 watch *connect.Client[ermite.WatchRequest, ermite.WatchResponse]
112}
113
114// Watch calls ermite.EventService.Watch.
115func (c *eventServiceClient) Watch(ctx context.Context, req *connect.Request[ermite.WatchRequest]) (*connect.ServerStreamForClient[ermite.WatchResponse], error) {
116 return c.watch.CallServerStream(ctx, req)
117}
118
119// EventServiceHandler is an implementation of the ermite.EventService service.
120type EventServiceHandler interface {
121 // Watch streams events until the client cancels the call or the server shuts
122 // down. Events are filtered by the caller's access: events of a private
123 // repository are only sent to callers that may read it.
124 //
125 // The events are repo_created, repo_updated, repo_deleted, pushed, gap and,
126 // for merge requests, merge_request_opened, merge_request_merged,
127 // merge_request_closed, comment_added, comment_edited, comment_deleted and
128 // comment_resolved (a thread resolved or reopened); for issues, issue_opened,
129 // issue_closed, issue_resolved, issue_reopened and issue_commented, and
130 // issue_submitted. Each one is delivered on the "repo:<name>" topic of its
131 // repository and on "home", subject to the visibility of the repository,
132 // except
133 // issue_submitted: it is delivered only on the "owner" topic, never on
134 // "home" or "repo:<name>", and carries no content (see IssueSubmitted).
135 //
136 // Servers with the feature "ci.runs" also publish run_updated and
137 // job_updated, only on the "repo:<name>" topic of their repository (never on
138 // "home"), subject to the same visibility. They carry the state after the
139 // change and are published when a run or a job is created, changes status
140 // or conclusion, or when one of its steps starts or ends (never per log
141 // line: follow a log with RunService.GetJobLog). The order of these events
142 // is not guaranteed, between jobs and runs or between two updates of the same
143 // one: a client keeps the copy with the higher Run.version or
144 // RunJob.version and drops the other. There is no event for a change of title or
145 // description: after a gap, or to see such changes, clients read the merge
146 // request again. A merge publishes
147 // merge_request_merged, then pushed for the target branch.
148 //
149 // The server keeps a bounded buffer of recent events. With resume_after set,
150 // buffered events after that id are replayed first, then live events follow.
151 // When resume_after is no longer buffered (or unknown), the stream begins
152 // with a Gap event, then continues with the oldest buffered event: the client
153 // must reload its state. Without resume_after, only new events are sent.
154 //
155 // The access of the caller is checked again for every event: the stream ends
156 // with unauthenticated when the token was revoked or has expired (the server
157 // may take a few seconds to notice). A repository that becomes private
158 // sends one last repo_updated to the callers who could read it before, with
159 // the new visibility and nothing else about it; no later event of it
160 // reaches them. The server limits the watchers: more than 64 topics is
161 // invalid_argument, and too many concurrent streams, in total or from one
162 // client, is resource_exhausted.
163 Watch(context.Context, *connect.Request[ermite.WatchRequest], *connect.ServerStream[ermite.WatchResponse]) error
164}
165
166// NewEventServiceHandler builds an HTTP handler from the service implementation. It returns the
167// path on which to mount the handler and the handler itself.
168//
169// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
170// and JSON codecs. They also support gzip compression.
171func NewEventServiceHandler(svc EventServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
172 eventServiceMethods := ermite.File_ermite_event_proto.Services().ByName("EventService").Methods()
173 eventServiceWatchHandler := connect.NewServerStreamHandler(
174 EventServiceWatchProcedure,
175 svc.Watch,
176 connect.WithSchema(eventServiceMethods.ByName("Watch")),
177 connect.WithHandlerOptions(opts...),
178 )
179 return "/ermite.EventService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
180 switch r.URL.Path {
181 case EventServiceWatchProcedure:
182 eventServiceWatchHandler.ServeHTTP(w, r)
183 default:
184 http.NotFound(w, r)
185 }
186 })
187}
188
189// UnimplementedEventServiceHandler returns CodeUnimplemented from all methods.
190type UnimplementedEventServiceHandler struct{}
191
192func (UnimplementedEventServiceHandler) Watch(context.Context, *connect.Request[ermite.WatchRequest], *connect.ServerStream[ermite.WatchResponse]) error {
193 return connect.NewError(connect.CodeUnimplemented, errors.New("ermite.EventService.Watch is not implemented"))
194}