// returns lookup result if it took less than the provided timeLimit.
// returns TimeLimitReached error if it took more than provided timeLimit.
// NOTE: use TestResponseTime() to check for normal response time.
// NOTE: use this only if you can't effort any long lookup time.
// WARNING: do not use short time periods.
// WARNING: if requests reaches the server and then it gets aborted, you'll still be charged for request.
returns lookup result if it took less than the provided timeLimit.
returns TimeLimitReached error if it took more than provided timeLimit.
NOTE: use TestResponseTime() to check for normal response time.
NOTE: use this only if you can't effort any long lookup time.
WARNING: do not use short time periods.
WARNING: if requests reaches the server and then it gets aborted, you'll still be charged for request.
// returns lookup result if it took less than the provided timeLimit . // returns TimeLimitReached error if it took more than provided timeLimit . // NOTE : use TestResponseTime () to check for normal response time . // NOTE : use this only if you can ' t effort any long lookup time . // WARNING : do not use short time periods . // WARNING : if requests reaches the server and then it gets aborted you ' ll still be charged for request .
func (c *Client) LookupWithTL(ip string, timeLimit time.Duration) (*IPLookup, error) {
	var result *IPLookup
	var err error
	c1 := make(chan string, 1)
	go func() {
		result, err = c.Lookup(ip)
		c1 <- "done"
	}()
	select {
	case <-c1:
		return result, err
	case <-time.After(timeLimit):
		return nil, TimeLimitReached
	}
}
func ( c * Client ) LookupWithTL ( ip string , timeLimit time . Duration ) ( * IPLookup , error ) { var result * IPLookup var err error c1 := make ( chan string , 1 ) go func ( ) { result , err = c . Lookup ( ip ) c1 <- " " } ( ) select { case <- c1 : return result , err case <- time . After ( timeLimit ) : return nil , TimeLimitReached } }
returns lookup result if it took less than the provided timeLimit.
returns lookup result if it took less than the provided timeLimit .