grpcservice

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 10, 2023 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package grpcservice contains the implementation of the test GRPC service.

Index

Constants

This section is empty.

Variables

View Source
var FeatureExplorer_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "main.FeatureExplorer",
	HandlerType: (*FeatureExplorerServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "GetFeature",
			Handler:    _FeatureExplorer_GetFeature_Handler,
		},
	},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "ListFeatures",
			Handler:       _FeatureExplorer_ListFeatures_Handler,
			ServerStreams: true,
		},
	},
	Metadata: "route_guide.proto",
}

FeatureExplorer_ServiceDesc is the grpc.ServiceDesc for FeatureExplorer service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_route_guide_proto protoreflect.FileDescriptor
View Source
var RouteGuide_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "main.RouteGuide",
	HandlerType: (*RouteGuideServer)(nil),
	Methods:     []grpc.MethodDesc{},
	Streams: []grpc.StreamDesc{
		{
			StreamName:    "RecordRoute",
			Handler:       _RouteGuide_RecordRoute_Handler,
			ClientStreams: true,
		},
		{
			StreamName:    "RouteChat",
			Handler:       _RouteGuide_RouteChat_Handler,
			ServerStreams: true,
			ClientStreams: true,
		},
	},
	Metadata: "route_guide.proto",
}

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)

Functions

func RegisterFeatureExplorerServer

func RegisterFeatureExplorerServer(s grpc.ServiceRegistrar, srv FeatureExplorerServer)

func RegisterRouteGuideServer

func RegisterRouteGuideServer(s grpc.ServiceRegistrar, srv RouteGuideServer)

Types

type Feature

type Feature struct {

	// The name of the feature.
	Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	// The point where the feature is detected.
	Location *Point `protobuf:"bytes,2,opt,name=location,proto3" json:"location,omitempty"`
	// contains filtered or unexported fields
}

A feature names something at a given point.

If a feature could not be named, the name is empty.

func LoadFeatures

func LoadFeatures(filePath string) []*Feature

LoadFeatures loads features from a JSON file.

func (*Feature) Descriptor deprecated

func (*Feature) Descriptor() ([]byte, []int)

Deprecated: Use Feature.ProtoReflect.Descriptor instead.

func (*Feature) GetLocation

func (x *Feature) GetLocation() *Point

func (*Feature) GetName

func (x *Feature) GetName() string

func (*Feature) ProtoMessage

func (*Feature) ProtoMessage()

func (*Feature) ProtoReflect

func (x *Feature) ProtoReflect() protoreflect.Message

func (*Feature) Reset

func (x *Feature) Reset()

func (*Feature) String

func (x *Feature) String() string

type FeatureExplorerClient

type FeatureExplorerClient 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) (FeatureExplorer_ListFeaturesClient, error)
}

FeatureExplorerClient is the client API for FeatureExplorer 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.

type FeatureExplorerImplementation

type FeatureExplorerImplementation struct {
	Logf func(format string, v ...any)
	UnimplementedFeatureExplorerServer
	// contains filtered or unexported fields
}

FeatureExplorerImplementation contains an implementation of the FeatureExplorer service.

func NewFeatureExplorerServer

func NewFeatureExplorerServer(features ...*Feature) *FeatureExplorerImplementation

NewFeatureExplorerServer creates a FeatureExplorer server.

func (*FeatureExplorerImplementation) GetFeature

func (s *FeatureExplorerImplementation) GetFeature(_ context.Context, point *Point) (*Feature, error)

GetFeature returns the feature at the given point.

func (*FeatureExplorerImplementation) ListFeatures

ListFeatures lists all features contained within the given bounding Rectangle.

type FeatureExplorerServer

type FeatureExplorerServer 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, FeatureExplorer_ListFeaturesServer) error
	// contains filtered or unexported methods
}

FeatureExplorerServer is the server API for FeatureExplorer service. All implementations must embed UnimplementedFeatureExplorerServer for forward compatibility

type FeatureExplorer_ListFeaturesClient

type FeatureExplorer_ListFeaturesClient interface {
	Recv() (*Feature, error)
	grpc.ClientStream
}

type FeatureExplorer_ListFeaturesServer

type FeatureExplorer_ListFeaturesServer interface {
	Send(*Feature) error
	grpc.ServerStream
}

type Point

type Point struct {
	Latitude  int32 `protobuf:"varint,1,opt,name=latitude,proto3" json:"latitude,omitempty"`
	Longitude int32 `protobuf:"varint,2,opt,name=longitude,proto3" json:"longitude,omitempty"`
	// contains filtered or unexported fields
}

Points are represented as latitude-longitude pairs in the E7 representation (degrees multiplied by 10**7 and rounded to the nearest integer). Latitudes should be in the range +/- 90 degrees and longitude should be in the range +/- 180 degrees (inclusive).

func (*Point) Descriptor deprecated

func (*Point) Descriptor() ([]byte, []int)

Deprecated: Use Point.ProtoReflect.Descriptor instead.

func (*Point) GetLatitude

func (x *Point) GetLatitude() int32

func (*Point) GetLongitude

func (x *Point) GetLongitude() int32

func (*Point) ProtoMessage

func (*Point) ProtoMessage()

func (*Point) ProtoReflect

func (x *Point) ProtoReflect() protoreflect.Message

func (*Point) Reset

func (x *Point) Reset()

func (*Point) String

func (x *Point) String() string

type Rectangle

type Rectangle struct {

	// One corner of the rectangle.
	Lo *Point `protobuf:"bytes,1,opt,name=lo,proto3" json:"lo,omitempty"`
	// The other corner of the rectangle.
	Hi *Point `protobuf:"bytes,2,opt,name=hi,proto3" json:"hi,omitempty"`
	// contains filtered or unexported fields
}

A latitude-longitude rectangle, represented as two diagonally opposite points "lo" and "hi".

func (*Rectangle) Descriptor deprecated

func (*Rectangle) Descriptor() ([]byte, []int)

Deprecated: Use Rectangle.ProtoReflect.Descriptor instead.

func (*Rectangle) GetHi

func (x *Rectangle) GetHi() *Point

func (*Rectangle) GetLo

func (x *Rectangle) GetLo() *Point

func (*Rectangle) ProtoMessage

func (*Rectangle) ProtoMessage()

func (*Rectangle) ProtoReflect

func (x *Rectangle) ProtoReflect() protoreflect.Message

func (*Rectangle) Reset

func (x *Rectangle) Reset()

func (*Rectangle) String

func (x *Rectangle) String() string

type RouteGuideClient

type RouteGuideClient interface {
	// 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) (RouteGuide_RecordRouteClient, 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) (RouteGuide_RouteChatClient, error)
}

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.

func NewRouteGuideClient

func NewRouteGuideClient(cc grpc.ClientConnInterface) RouteGuideClient

type RouteGuideImplementation

type RouteGuideImplementation struct {
	Logf func(format string, v ...any)
	UnimplementedRouteGuideServer
	// contains filtered or unexported fields
}

RouteGuideImplementation contains an implementation of the RouteGuide service.

func NewRouteGuideServer

func NewRouteGuideServer(features ...*Feature) *RouteGuideImplementation

NewRouteGuideServer creates a RouteGuide server.

func (*RouteGuideImplementation) RecordRoute

RecordRoute records a route composited of a sequence of points.

It gets a stream of points, and responds with statistics about the "trip": number of points, number of known features visited, total distance traveled, and total time spent.

func (*RouteGuideImplementation) RouteChat

RouteChat receives a stream of message/location pairs, and responds with a stream of all previous messages at each of those locations.

type RouteGuideServer

type RouteGuideServer interface {
	// A client-to-server streaming RPC.
	//
	// Accepts a stream of Points on a route being traversed, returning a
	// RouteSummary when traversal is completed.
	RecordRoute(RouteGuide_RecordRouteServer) 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(RouteGuide_RouteChatServer) error
	// contains filtered or unexported methods
}

RouteGuideServer is the server API for RouteGuide service. All implementations must embed UnimplementedRouteGuideServer for forward compatibility

type RouteGuide_RecordRouteClient

type RouteGuide_RecordRouteClient interface {
	Send(*Point) error
	CloseAndRecv() (*RouteSummary, error)
	grpc.ClientStream
}

type RouteGuide_RecordRouteServer

type RouteGuide_RecordRouteServer interface {
	SendAndClose(*RouteSummary) error
	Recv() (*Point, error)
	grpc.ServerStream
}

type RouteGuide_RouteChatClient

type RouteGuide_RouteChatClient interface {
	Send(*RouteNote) error
	Recv() (*RouteNote, error)
	grpc.ClientStream
}

type RouteGuide_RouteChatServer

type RouteGuide_RouteChatServer interface {
	Send(*RouteNote) error
	Recv() (*RouteNote, error)
	grpc.ServerStream
}

type RouteNote

type RouteNote struct {

	// The location from which the message is sent.
	Location *Point `protobuf:"bytes,1,opt,name=location,proto3" json:"location,omitempty"`
	// The message to be sent.
	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

A RouteNote is a message sent while at a given point.

func (*RouteNote) Descriptor deprecated

func (*RouteNote) Descriptor() ([]byte, []int)

Deprecated: Use RouteNote.ProtoReflect.Descriptor instead.

func (*RouteNote) GetLocation

func (x *RouteNote) GetLocation() *Point

func (*RouteNote) GetMessage

func (x *RouteNote) GetMessage() string

func (*RouteNote) ProtoMessage

func (*RouteNote) ProtoMessage()

func (*RouteNote) ProtoReflect

func (x *RouteNote) ProtoReflect() protoreflect.Message

func (*RouteNote) Reset

func (x *RouteNote) Reset()

func (*RouteNote) String

func (x *RouteNote) String() string

type RouteSummary

type RouteSummary struct {

	// The number of points received.
	PointCount int32 `protobuf:"varint,1,opt,name=point_count,json=pointCount,proto3" json:"point_count,omitempty"`
	// The number of known features passed while traversing the route.
	FeatureCount int32 `protobuf:"varint,2,opt,name=feature_count,json=featureCount,proto3" json:"feature_count,omitempty"`
	// The distance covered in metres.
	Distance int32 `protobuf:"varint,3,opt,name=distance,proto3" json:"distance,omitempty"`
	// The duration of the traversal in seconds.
	ElapsedTime int32 `protobuf:"varint,4,opt,name=elapsed_time,json=elapsedTime,proto3" json:"elapsed_time,omitempty"`
	// contains filtered or unexported fields
}

A RouteSummary is received in response to a RecordRoute rpc.

It contains the number of individual points received, the number of detected features, and the total distance covered as the cumulative sum of the distance between each point.

func (*RouteSummary) Descriptor deprecated

func (*RouteSummary) Descriptor() ([]byte, []int)

Deprecated: Use RouteSummary.ProtoReflect.Descriptor instead.

func (*RouteSummary) GetDistance

func (x *RouteSummary) GetDistance() int32

func (*RouteSummary) GetElapsedTime

func (x *RouteSummary) GetElapsedTime() int32

func (*RouteSummary) GetFeatureCount

func (x *RouteSummary) GetFeatureCount() int32

func (*RouteSummary) GetPointCount

func (x *RouteSummary) GetPointCount() int32

func (*RouteSummary) ProtoMessage

func (*RouteSummary) ProtoMessage()

func (*RouteSummary) ProtoReflect

func (x *RouteSummary) ProtoReflect() protoreflect.Message

func (*RouteSummary) Reset

func (x *RouteSummary) Reset()

func (*RouteSummary) String

func (x *RouteSummary) String() string

type UnimplementedFeatureExplorerServer

type UnimplementedFeatureExplorerServer struct {
}

UnimplementedFeatureExplorerServer must be embedded to have forward compatible implementations.

func (UnimplementedFeatureExplorerServer) GetFeature

func (UnimplementedFeatureExplorerServer) ListFeatures

type UnimplementedRouteGuideServer

type UnimplementedRouteGuideServer struct {
}

UnimplementedRouteGuideServer must be embedded to have forward compatible implementations.

func (UnimplementedRouteGuideServer) RecordRoute

func (UnimplementedRouteGuideServer) RouteChat

type UnsafeFeatureExplorerServer

type UnsafeFeatureExplorerServer interface {
	// contains filtered or unexported methods
}

UnsafeFeatureExplorerServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to FeatureExplorerServer will result in compilation errors.

type UnsafeRouteGuideServer

type UnsafeRouteGuideServer interface {
	// contains filtered or unexported methods
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL