grpc

package
v0.0.0-...-45a9bcf Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package grpc provides a gRPC client that fits the gRPC server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGRPCTLSServer

func NewGRPCTLSServer(t *testing.T, addr string, useTLS bool) (*exec.Cmd, context.CancelFunc)

NewGRPCTLSServer triggers an external go tls client that runs `numRequests` HTTPs requests to `serverAddr`. Returns the command executed and a callback to start sending requests.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a single gRPC client that fits the gRPC server.

func NewClient

func NewClient(addr string, options Options, withTLS bool) (Client, error)

NewClient returns a new gRPC client

func (*Client) Close

func (c *Client) Close()

Close terminates the client connection.

func (*Client) GetFeature

func (c *Client) GetFeature(ctx context.Context, long, lat int32) error

GetFeature activates the GetFeature RPC.

func (*Client) HandleStream

func (c *Client) HandleStream(ctx context.Context, numberOfMessages int32) error

HandleStream performs a gRPC stream call to FetchResponse RPC of StreamService service.

func (*Client) HandleUnary

func (c *Client) HandleUnary(ctx context.Context, name string) error

HandleUnary performs a gRPC unary call to SayHello RPC of the greeter service.

func (*Client) ListFeatures

func (c *Client) ListFeatures(ctx context.Context, longLo, latLo, longHi, latHi int32) error

ListFeatures activates the ListFeatures RPC.

type Options

type Options struct {
	// DialTimeout the timeout before giving up on a dialing to the server. Set as 0 for the default (currently 5 seconds).
	DialTimeout time.Duration
	// CustomDialer allows to modify the underlying dialer used by grpc package. Set nil for the default dialer.
	CustomDialer *net.Dialer
}

Options allows to determine the behavior of the client.

type Server

type Server struct {
	Address string

	pb.UnimplementedGreeterServer
	routeguide.UnimplementedRouteGuideServer
	pbStream.UnimplementedMathServer
	// contains filtered or unexported fields
}

Server is used to implement helloworld.GreeterServer.

func NewServer

func NewServer(addr string, enableTLS bool) (*Server, error)

NewServer returns a new instance of the gRPC server.

func NewServerWithoutBind

func NewServerWithoutBind(opts ...grpc.ServerOption) *Server

NewServerWithoutBind returns a new instance of the gRPC server.

func (*Server) GetFeature

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

GetFeature returns the feature at the given point.

func (*Server) GetGRPCServer

func (s *Server) GetGRPCServer() *grpc.Server

GetGRPCServer returns the gRPC server.

func (*Server) ListFeatures

ListFeatures lists all features contained within the given bounding Rectangle.

func (*Server) Max

func (*Server) Max(srv pbStream.Math_MaxServer) error

Max implements MathServer.

func (*Server) RecordRoute

func (s *Server) RecordRoute(stream routeguide.RouteGuide_RecordRouteServer) error

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 (*Server) RouteChat

func (s *Server) RouteChat(stream routeguide.RouteGuide_RouteChatServer) error

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

func (*Server) Run

func (s *Server) Run()

Run starts the gRPC server.

func (*Server) SayHello

func (*Server) SayHello(_ context.Context, in *pb.HelloRequest) (*pb.HelloReply, error)

SayHello implements helloworld.GreeterServer.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the gRPC server.

Directories

Path Synopsis
Package main provides a simple gRPC server that can be used for testing.
Package main provides a simple gRPC server that can be used for testing.

Jump to

Keyboard shortcuts

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