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