// FindNearest implements gRPC driver interface
FindNearest implements gRPC driver interface
// FindNearest implements gRPC driver interface
func (s *Server) FindNearest(ctx context.Context, location *DriverLocationRequest) (*DriverLocationResponse, error) {
	s.logger.For(ctx).Info("Searching for nearby drivers", zap.String("location", location.Location))
	driverIDs := s.redis.FindDriverIDs(ctx, location.Location)
	retMe := make([]*DriverLocation, len(driverIDs))
	for i, driverID := range driverIDs {
		var drv Driver
		var err error
		for i := 0; i < 3; i++ {
			drv, err = s.redis.GetDriver(ctx, driverID)
			if err == nil {
				break
			}
			s.logger.For(ctx).Error("Retrying GetDriver after error", zap.Int("retry_no", i+1), zap.Error(err))
		}
		if err != nil {
			s.logger.For(ctx).Error("Failed to get driver after 3 attempts", zap.Error(err))
			return nil, err
		}
		retMe[i] = &DriverLocation{
			DriverID: drv.DriverID,
			Location: drv.Location,
		}
	}
	s.logger.For(ctx).Info("Search successful", zap.Int("num_drivers", len(retMe)))
	return &DriverLocationResponse{Locations: retMe}, nil
}
func ( s * Server ) FindNearest ( ctx context . Context , location * DriverLocationRequest ) ( * DriverLocationResponse , error ) { s . logger . For ( ctx ) . Info ( " " , zap . String ( " " , location . Location ) ) driverIDs := s . redis . FindDriverIDs ( ctx , location . Location ) retMe := make ( [ ] * DriverLocation , len ( driverIDs ) ) for i , driverID := range driverIDs { var drv Driver var err error for i := 0 ; i < 3 ; i ++ { drv , err = s . redis . GetDriver ( ctx , driverID ) if err == nil { break } s . logger . For ( ctx ) . Error ( " " , zap . Int ( " " , i + 1 ) , zap . Error ( err ) ) } if err != nil { s . logger . For ( ctx ) . Error ( " " , zap . Error ( err ) ) return nil , err } retMe [ i ] = & DriverLocation { DriverID : drv . DriverID , Location : drv . Location , } } s . logger . For ( ctx ) . Info ( " " , zap . Int ( " " , len ( retMe ) ) ) return & DriverLocationResponse { Locations : retMe } , nil }
FindNearest implements gRPC driver interface
FindNearest implements gRPC driver interface