func (server *PortServer) Load(_ *empty.Empty, stream proto.Storage_LoadServer) error {
	ctx := stream.Context()

	if err := server.PortStorage.Each(
		func(id string, port *proto.Port) error {
			select {
			case <-ctx.Done():
				return ctx.Err()
			default:
			}

			if err := stream.Send(&proto.Payload{
				Id:   id,
				Port: port,
			}); err != nil {
				return err
			}

			return nil
		},
	); err != nil {
		return status.Errorf(codes.Internal, "unexpected error: %v", err)
	}

	return nil
}
// Load is a server-streaming RPC to return all available ports.
// TODO:
// - logging
Load is a server-streaming RPC to return all available ports.
TODO:
- logging
// Load is a server - streaming RPC to return all available ports . // TODO : // - logging
func (server *PortServer) Load(_ *empty.Empty, stream proto.Storage_LoadServer) error {
	ctx := stream.Context()
	if err := server.PortStorage.Each(
		func(id string, port *proto.Port) error {
			select {
			case <-ctx.Done():
				return ctx.Err()
			default:
			}
			if err := stream.Send(&proto.Payload{
				Id:   id,
				Port: port,
			}); err != nil {
				return err
			}
			return nil
		},
	); err != nil {
		return status.Errorf(codes.Internal, "unexpected error: %v", err)
	}
	return nil
}
func ( server * PortServer ) Load ( _ * empty . Empty , stream proto . Storage_LoadServer ) error { ctx := stream . Context ( ) if err := server . PortStorage . Each ( func ( id string , port * proto . Port ) error { select { case <- ctx . Done ( ) : return ctx . Err ( ) default : } if err := stream . Send ( & proto . Payload { Id : id , Port : port , } ) ; err != nil { return err } return nil } , ) ; err != nil { return status . Errorf ( codes . Internal , " " , err ) } return nil }
Load is a server-streaming RPC to return all available ports.
Load is a server - streaming RPC to return all available ports .