fakegrpclb

package
v0.0.0-...-7d1ee88 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package fakegrpclb provides a fake implementation of the grpclb server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	lbgrpc.UnimplementedLoadBalancerServer
	// contains filtered or unexported fields
}

Server is a fake implementation of the grpclb LoadBalancer service. It does not support stats reporting from clients, and always sends back a static list of backends to the client to balance load across.

It is safe for concurrent access.

func NewServer

func NewServer(params ServerParams) (*Server, error)

NewServer creates a new Server with passed in params. Returns a non-nil error if the params are invalid.

func (*Server) Address

func (s *Server) Address() string

Address returns the host:port on which the LoadBalancer service is serving.

func (*Server) BalanceLoad

func (s *Server) BalanceLoad(stream lbgrpc.LoadBalancer_BalanceLoadServer) error

BalanceLoad provides a fake implementation of the LoadBalancer service.

func (*Server) Serve

func (s *Server) Serve() error

Serve starts serving the LoadBalancer service on a gRPC server.

It returns early with a non-nil error if it is unable to start serving. Otherwise, it blocks until Stop() is called, at which point it returns the error returned by the underlying grpc.Server's Serve() method.

func (*Server) Stop

func (s *Server) Stop()

Stop stops serving the LoadBalancer service and unblocks the preceding call to Serve().

type ServerParams

type ServerParams struct {
	ListenPort    int                 // Listening port for the balancer server.
	ServerOptions []grpc.ServerOption // gRPC options for the balancer server.

	LoadBalancedServiceName string   // Service name being load balanced for.
	LoadBalancedServicePort int      // Service port being load balanced for.
	BackendAddresses        []string // Service backends to balance load across.
	ShortStream             bool     // End balancer stream after sending server list.
}

ServerParams wraps options passed while creating a Server.

Jump to

Keyboard shortcuts

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