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