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.
| 57 | // |
| 58 | // It is safe for concurrent access. |
| 59 | type Server struct { |
| 60 | lbgrpc.UnimplementedLoadBalancerServer |
| 61 | |
| 62 | // Options copied over from ServerParams passed to NewServer. |
| 63 | sOpts []grpc.ServerOption // gRPC server options. |
| 64 | serviceName string // Service name being load balanced for. |
| 65 | servicePort int // Service port being load balanced for. |
| 66 | shortStream bool // End balancer stream after sending server list. |
| 67 | |
| 68 | // Values initialized using ServerParams passed to NewServer. |
| 69 | backends []*lbpb.Server // Service backends to balance load across. |
| 70 | lis net.Listener // Listener for grpc connections to the LoadBalancer service. |
| 71 | |
| 72 | // mu guards access to below fields. |
| 73 | mu sync.Mutex |
| 74 | grpcServer *grpc.Server // Underlying grpc server. |
| 75 | address string // Actual listening address. |
| 76 | |
| 77 | stopped chan struct{} // Closed when Stop() is called. |
| 78 | } |
| 79 | |
| 80 | // NewServer creates a new Server with passed in params. Returns a non-nil error |
| 81 | // if the params are invalid. |
nothing calls this directly
no outgoing calls
no test coverage detected