// SPDX-License-Identifier: MIT // Code generated by protoc-gen-connect-go. DO NOT EDIT. // // Source: ermite/event.proto package ermiteconnect import ( ermite "bnema.dev/ermite-api/gen/ermite" connect "connectrpc.com/connect" context "context" errors "errors" http "net/http" strings "strings" ) // This is a compile-time assertion to ensure that this generated file and the connect package are // compatible. If you get a compiler error that this constant is not defined, this code was // generated with a version of connect newer than the one compiled into your binary. You can fix the // problem by either regenerating this code with an older version of connect or updating the connect // version compiled into your binary. const _ = connect.IsAtLeastVersion1_13_0 const ( // EventServiceName is the fully-qualified name of the EventService service. EventServiceName = "ermite.EventService" ) // These constants are the fully-qualified names of the RPCs defined in this package. They're // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. // // Note that these are different from the fully-qualified method names used by // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to // reflection-formatted method names, remove the leading slash and convert the remaining slash to a // period. const ( // EventServiceWatchProcedure is the fully-qualified name of the EventService's Watch RPC. EventServiceWatchProcedure = "/ermite.EventService/Watch" ) // EventServiceClient is a client for the ermite.EventService service. type EventServiceClient interface { // Watch streams events until the client cancels the call or the server shuts // down. Events are filtered by the caller's access: events of a private // repository are only sent to callers that may read it. // // The events are repo_created, repo_updated, repo_deleted, pushed, gap and, // for merge requests, merge_request_opened, merge_request_merged, // merge_request_closed, comment_added, comment_edited, comment_deleted and // comment_resolved (a thread resolved or reopened). Each one is delivered on the // "repo:" topic of its repository and on "home", subject to the // visibility of the repository. // // Servers with the feature "ci.runs" also publish run_updated and // job_updated, only on the "repo:" topic of their repository (never on // "home"), subject to the same visibility. They carry the state after the // change and are published when a run or a job is created, changes status // or conclusion, or when one of its steps starts or ends (never per log // line: follow a log with RunService.GetJobLog). The order of these events // is not guaranteed, between jobs and runs or between two updates of the same // one: a client keeps the copy with the higher Run.version or // RunJob.version and drops the other. There is no event for a change of title or // description: after a gap, or to see such changes, clients read the merge // request again. A merge publishes // merge_request_merged, then pushed for the target branch. // // The server keeps a bounded buffer of recent events. With resume_after set, // buffered events after that id are replayed first, then live events follow. // When resume_after is no longer buffered (or unknown), the stream begins // with a Gap event, then continues with the oldest buffered event: the client // must reload its state. Without resume_after, only new events are sent. // // The access of the caller is checked again for every event: the stream ends // with unauthenticated when the token was revoked or has expired (the server // may take a few seconds to notice). A repository that becomes private // sends one last repo_updated to the callers who could read it before, with // the new visibility and nothing else about it; no later event of it // reaches them. The server limits the watchers: more than 64 topics is // invalid_argument, and too many concurrent streams, in total or from one // client, is resource_exhausted. Watch(context.Context, *connect.Request[ermite.WatchRequest]) (*connect.ServerStreamForClient[ermite.WatchResponse], error) } // NewEventServiceClient constructs a client for the ermite.EventService service. By default, it // uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends // uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or // connect.WithGRPCWeb() options. // // The URL supplied here should be the base URL for the Connect or gRPC server (for example, // http://api.acme.com or https://acme.com/grpc). func NewEventServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) EventServiceClient { baseURL = strings.TrimRight(baseURL, "/") eventServiceMethods := ermite.File_ermite_event_proto.Services().ByName("EventService").Methods() return &eventServiceClient{ watch: connect.NewClient[ermite.WatchRequest, ermite.WatchResponse]( httpClient, baseURL+EventServiceWatchProcedure, connect.WithSchema(eventServiceMethods.ByName("Watch")), connect.WithClientOptions(opts...), ), } } // eventServiceClient implements EventServiceClient. type eventServiceClient struct { watch *connect.Client[ermite.WatchRequest, ermite.WatchResponse] } // Watch calls ermite.EventService.Watch. func (c *eventServiceClient) Watch(ctx context.Context, req *connect.Request[ermite.WatchRequest]) (*connect.ServerStreamForClient[ermite.WatchResponse], error) { return c.watch.CallServerStream(ctx, req) } // EventServiceHandler is an implementation of the ermite.EventService service. type EventServiceHandler interface { // Watch streams events until the client cancels the call or the server shuts // down. Events are filtered by the caller's access: events of a private // repository are only sent to callers that may read it. // // The events are repo_created, repo_updated, repo_deleted, pushed, gap and, // for merge requests, merge_request_opened, merge_request_merged, // merge_request_closed, comment_added, comment_edited, comment_deleted and // comment_resolved (a thread resolved or reopened). Each one is delivered on the // "repo:" topic of its repository and on "home", subject to the // visibility of the repository. // // Servers with the feature "ci.runs" also publish run_updated and // job_updated, only on the "repo:" topic of their repository (never on // "home"), subject to the same visibility. They carry the state after the // change and are published when a run or a job is created, changes status // or conclusion, or when one of its steps starts or ends (never per log // line: follow a log with RunService.GetJobLog). The order of these events // is not guaranteed, between jobs and runs or between two updates of the same // one: a client keeps the copy with the higher Run.version or // RunJob.version and drops the other. There is no event for a change of title or // description: after a gap, or to see such changes, clients read the merge // request again. A merge publishes // merge_request_merged, then pushed for the target branch. // // The server keeps a bounded buffer of recent events. With resume_after set, // buffered events after that id are replayed first, then live events follow. // When resume_after is no longer buffered (or unknown), the stream begins // with a Gap event, then continues with the oldest buffered event: the client // must reload its state. Without resume_after, only new events are sent. // // The access of the caller is checked again for every event: the stream ends // with unauthenticated when the token was revoked or has expired (the server // may take a few seconds to notice). A repository that becomes private // sends one last repo_updated to the callers who could read it before, with // the new visibility and nothing else about it; no later event of it // reaches them. The server limits the watchers: more than 64 topics is // invalid_argument, and too many concurrent streams, in total or from one // client, is resource_exhausted. Watch(context.Context, *connect.Request[ermite.WatchRequest], *connect.ServerStream[ermite.WatchResponse]) error } // NewEventServiceHandler builds an HTTP handler from the service implementation. It returns the // path on which to mount the handler and the handler itself. // // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf // and JSON codecs. They also support gzip compression. func NewEventServiceHandler(svc EventServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { eventServiceMethods := ermite.File_ermite_event_proto.Services().ByName("EventService").Methods() eventServiceWatchHandler := connect.NewServerStreamHandler( EventServiceWatchProcedure, svc.Watch, connect.WithSchema(eventServiceMethods.ByName("Watch")), connect.WithHandlerOptions(opts...), ) return "/ermite.EventService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case EventServiceWatchProcedure: eventServiceWatchHandler.ServeHTTP(w, r) default: http.NotFound(w, r) } }) } // UnimplementedEventServiceHandler returns CodeUnimplemented from all methods. type UnimplementedEventServiceHandler struct{} func (UnimplementedEventServiceHandler) Watch(context.Context, *connect.Request[ermite.WatchRequest], *connect.ServerStream[ermite.WatchResponse]) error { return connect.NewError(connect.CodeUnimplemented, errors.New("ermite.EventService.Watch is not implemented")) }