Debian Codegraph @

ping/v1/pingv1connect/services.connect.go

raw symbols SCIP
1 // Code generated by protoc-gen-connect-go. DO NOT EDIT.
2 //
3 // Source: ping/v1/services.proto
4
5 package pingv1connect
6
7 import (
8 v1 "code.forgejo.org/forgejo/actions-proto/ping/v1"
9 connect "connectrpc.com/connect"
10 context "context"
11 errors "errors"
12 http "net/http"
13 strings "strings"
14 )
15
16 // This is a compile-time assertion to ensure that this generated file and the connect package are
17 // compatible. If you get a compiler error that this constant is not defined, this code was
18 // generated with a version of connect newer than the one compiled into your binary. You can fix the
19 // problem by either regenerating this code with an older version of connect or updating the connect
20 // version compiled into your binary.
21 const _ = connect.IsAtLeastVersion1_13_0
22
23 const (
24 // PingServiceName is the fully-qualified name of the PingService service.
25 PingServiceName = "ping.v1.PingService"
26 )
27
28 // These constants are the fully-qualified names of the RPCs defined in this package. They're
29 // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route.
30 //
31 // Note that these are different from the fully-qualified method names used by
32 // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to
33 // reflection-formatted method names, remove the leading slash and convert the remaining slash to a
34 // period.
35 const (
36 // PingServicePingProcedure is the fully-qualified name of the PingService's Ping RPC.
37 PingServicePingProcedure = "/ping.v1.PingService/Ping"
38 )
39
40 // These variables are the protoreflect.Descriptor objects for the RPCs defined in this package.
41 var (
42 pingServiceServiceDescriptor = v1.File_ping_v1_services_proto.Services().ByName("PingService")
43 pingServicePingMethodDescriptor = pingServiceServiceDescriptor.Methods().ByName("Ping")
44 )
45
46 // PingServiceClient is a client for the ping.v1.PingService service.
47 type PingServiceClient interface {
48 Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error)
49 }
50
51 // NewPingServiceClient constructs a client for the ping.v1.PingService service. By default, it uses
52 // the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends
53 // uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or
54 // connect.WithGRPCWeb() options.
55 //
56 // The URL supplied here should be the base URL for the Connect or gRPC server (for example,
57 // http://api.acme.com or https://acme.com/grpc).
58 func NewPingServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) PingServiceClient {
59 baseURL = strings.TrimRight(baseURL, "/")
60 return &pingServiceClient{
61 ping: connect.NewClient[v1.PingRequest, v1.PingResponse](
62 httpClient,
63 baseURL+PingServicePingProcedure,
64 connect.WithSchema(pingServicePingMethodDescriptor),
65 connect.WithClientOptions(opts...),
66 ),
67 }
68 }
69
70 // pingServiceClient implements PingServiceClient.
71 type pingServiceClient struct {
72 ping *connect.Client[v1.PingRequest, v1.PingResponse]
73 }
74
75 // Ping calls ping.v1.PingService.Ping.
76 func (c *pingServiceClient) Ping(ctx context.Context, req *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error) {
77 return c.ping.CallUnary(ctx, req)
78 }
79
80 // PingServiceHandler is an implementation of the ping.v1.PingService service.
81 type PingServiceHandler interface {
82 Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error)
83 }
84
85 // NewPingServiceHandler builds an HTTP handler from the service implementation. It returns the path
86 // on which to mount the handler and the handler itself.
87 //
88 // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf
89 // and JSON codecs. They also support gzip compression.
90 func NewPingServiceHandler(svc PingServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) {
91 pingServicePingHandler := connect.NewUnaryHandler(
92 PingServicePingProcedure,
93 svc.Ping,
94 connect.WithSchema(pingServicePingMethodDescriptor),
95 connect.WithHandlerOptions(opts...),
96 )
97 return "/ping.v1.PingService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
98 switch r.URL.Path {
99 case PingServicePingProcedure:
100 pingServicePingHandler.ServeHTTP(w, r)
101 default:
102 http.NotFound(w, r)
103 }
104 })
105 }
106
107 // UnimplementedPingServiceHandler returns CodeUnimplemented from all methods.
108 type UnimplementedPingServiceHandler struct{}
109
110 func (UnimplementedPingServiceHandler) Ping(context.Context, *connect.Request[v1.PingRequest]) (*connect.Response[v1.PingResponse], error) {
111 return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ping.v1.PingService.Ping is not implemented"))
112 }