// Copyright 2015 gRPC authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.5.1 // - protoc v5.27.1 // source: examples/route_guide/routeguide/route_guide.proto package routeguide import ( context "context" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" ) // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. // Requires gRPC-Go v1.64.0 or later. const _ = grpc.SupportPackageIsVersion9 const ( RouteGuide_GetFeature_FullMethodName = "/routeguide.RouteGuide/GetFeature" RouteGuide_ListFeatures_FullMethodName = "/routeguide.RouteGuide/ListFeatures" RouteGuide_RecordRoute_FullMethodName = "/routeguide.RouteGuide/RecordRoute" RouteGuide_RouteChat_FullMethodName = "/routeguide.RouteGuide/RouteChat" ) // RouteGuideClient is the client API for RouteGuide service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. // // Interface exported by the server. type RouteGuideClient interface { // A simple RPC. // // Obtains the feature at a given position. // // A feature with an empty name is returned if there's no feature at the given // position. GetFeature(ctx context.Context, in *Point, opts ...grpc.CallOption) (*Feature, error) // A server-to-client streaming RPC. // // Obtains the Features available within the given Rectangle. Results are // streamed rather than returned at once (e.g. in a response message with a // repeated field), as the rectangle may cover a large area and contain a // huge number of features. ListFeatures(ctx context.Context, in *Rectangle, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Feature], error) // A client-to-server streaming RPC. // // Accepts a stream of Points on a route being traversed, returning a // RouteSummary when traversal is completed. RecordRoute(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[Point, RouteSummary], error) // A Bidirectional streaming RPC. // // Accepts a stream of RouteNotes sent while a route is being traversed, // while receiving other RouteNotes (e.g. from other users). RouteChat(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[RouteNote, RouteNote], error) } type routeGuideClient struct { cc grpc.ClientConnInterface } func NewRouteGuideClient(cc grpc.ClientConnInterface) RouteGuideClient { return &routeGuideClient{cc} } func (c *routeGuideClient) GetFeature(ctx context.Context, in *Point, opts ...grpc.CallOption) (*Feature, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Feature) err := c.cc.Invoke(ctx, RouteGuide_GetFeature_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } func (c *routeGuideClient) ListFeatures(ctx context.Context, in *Rectangle, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Feature], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &RouteGuide_ServiceDesc.Streams[0], RouteGuide_ListFeatures_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[Rectangle, Feature]{ClientStream: stream} if err := x.ClientStream.SendMsg(in); err != nil { return nil, err } if err := x.ClientStream.CloseSend(); err != nil { return nil, err } return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type RouteGuide_ListFeaturesClient = grpc.ServerStreamingClient[Feature] func (c *routeGuideClient) RecordRoute(ctx context.Context, opts ...grpc.CallOption) (grpc.ClientStreamingClient[Point, RouteSummary], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &RouteGuide_ServiceDesc.Streams[1], RouteGuide_RecordRoute_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[Point, RouteSummary]{ClientStream: stream} return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type RouteGuide_RecordRouteClient = grpc.ClientStreamingClient[Point, RouteSummary] func (c *routeGuideClient) RouteChat(ctx context.Context, opts ...grpc.CallOption) (grpc.BidiStreamingClient[RouteNote, RouteNote], error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) stream, err := c.cc.NewStream(ctx, &RouteGuide_ServiceDesc.Streams[2], RouteGuide_RouteChat_FullMethodName, cOpts...) if err != nil { return nil, err } x := &grpc.GenericClientStream[RouteNote, RouteNote]{ClientStream: stream} return x, nil } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type RouteGuide_RouteChatClient = grpc.BidiStreamingClient[RouteNote, RouteNote] // RouteGuideServer is the server API for RouteGuide service. // All implementations must embed UnimplementedRouteGuideServer // for forward compatibility. // // Interface exported by the server. type RouteGuideServer interface { // A simple RPC. // // Obtains the feature at a given position. // // A feature with an empty name is returned if there's no feature at the given // position. GetFeature(context.Context, *Point) (*Feature, error) // A server-to-client streaming RPC. // // Obtains the Features available within the given Rectangle. Results are // streamed rather than returned at once (e.g. in a response message with a // repeated field), as the rectangle may cover a large area and contain a // huge number of features. ListFeatures(*Rectangle, grpc.ServerStreamingServer[Feature]) error // A client-to-server streaming RPC. // // Accepts a stream of Points on a route being traversed, returning a // RouteSummary when traversal is completed. RecordRoute(grpc.ClientStreamingServer[Point, RouteSummary]) error // A Bidirectional streaming RPC. // // Accepts a stream of RouteNotes sent while a route is being traversed, // while receiving other RouteNotes (e.g. from other users). RouteChat(grpc.BidiStreamingServer[RouteNote, RouteNote]) error mustEmbedUnimplementedRouteGuideServer() } // UnimplementedRouteGuideServer must be embedded to have // forward compatible implementations. // // NOTE: this should be embedded by value instead of pointer to avoid a nil // pointer dereference when methods are called. type UnimplementedRouteGuideServer struct{} func (UnimplementedRouteGuideServer) GetFeature(context.Context, *Point) (*Feature, error) { return nil, status.Errorf(codes.Unimplemented, "method GetFeature not implemented") } func (UnimplementedRouteGuideServer) ListFeatures(*Rectangle, grpc.ServerStreamingServer[Feature]) error { return status.Errorf(codes.Unimplemented, "method ListFeatures not implemented") } func (UnimplementedRouteGuideServer) RecordRoute(grpc.ClientStreamingServer[Point, RouteSummary]) error { return status.Errorf(codes.Unimplemented, "method RecordRoute not implemented") } func (UnimplementedRouteGuideServer) RouteChat(grpc.BidiStreamingServer[RouteNote, RouteNote]) error { return status.Errorf(codes.Unimplemented, "method RouteChat not implemented") } func (UnimplementedRouteGuideServer) mustEmbedUnimplementedRouteGuideServer() {} func (UnimplementedRouteGuideServer) testEmbeddedByValue() {} // UnsafeRouteGuideServer may be embedded to opt out of forward compatibility for this service. // Use of this interface is not recommended, as added methods to RouteGuideServer will // result in compilation errors. type UnsafeRouteGuideServer interface { mustEmbedUnimplementedRouteGuideServer() } func RegisterRouteGuideServer(s grpc.ServiceRegistrar, srv RouteGuideServer) { // If the following call panics, it indicates UnimplementedRouteGuideServer was // embedded by pointer and is nil. This will cause panics if an // unimplemented method is ever invoked, so we test this at initialization // time to prevent it from happening at runtime later due to I/O. if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { t.testEmbeddedByValue() } s.RegisterService(&RouteGuide_ServiceDesc, srv) } func _RouteGuide_GetFeature_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(Point) if err := dec(in); err != nil { return nil, err } if interceptor == nil { return srv.(RouteGuideServer).GetFeature(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, FullMethod: RouteGuide_GetFeature_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(RouteGuideServer).GetFeature(ctx, req.(*Point)) } return interceptor(ctx, in, info, handler) } func _RouteGuide_ListFeatures_Handler(srv interface{}, stream grpc.ServerStream) error { m := new(Rectangle) if err := stream.RecvMsg(m); err != nil { return err } return srv.(RouteGuideServer).ListFeatures(m, &grpc.GenericServerStream[Rectangle, Feature]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type RouteGuide_ListFeaturesServer = grpc.ServerStreamingServer[Feature] func _RouteGuide_RecordRoute_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(RouteGuideServer).RecordRoute(&grpc.GenericServerStream[Point, RouteSummary]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type RouteGuide_RecordRouteServer = grpc.ClientStreamingServer[Point, RouteSummary] func _RouteGuide_RouteChat_Handler(srv interface{}, stream grpc.ServerStream) error { return srv.(RouteGuideServer).RouteChat(&grpc.GenericServerStream[RouteNote, RouteNote]{ServerStream: stream}) } // This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name. type RouteGuide_RouteChatServer = grpc.BidiStreamingServer[RouteNote, RouteNote] // RouteGuide_ServiceDesc is the grpc.ServiceDesc for RouteGuide service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) var RouteGuide_ServiceDesc = grpc.ServiceDesc{ ServiceName: "routeguide.RouteGuide", HandlerType: (*RouteGuideServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "GetFeature", Handler: _RouteGuide_GetFeature_Handler, }, }, Streams: []grpc.StreamDesc{ { StreamName: "ListFeatures", Handler: _RouteGuide_ListFeatures_Handler, ServerStreams: true, }, { StreamName: "RecordRoute", Handler: _RouteGuide_RecordRoute_Handler, ClientStreams: true, }, { StreamName: "RouteChat", Handler: _RouteGuide_RouteChat_Handler, ServerStreams: true, ClientStreams: true, }, }, Metadata: "examples/route_guide/routeguide/route_guide.proto", }