func NewPClient(stdClient *http.Client, maxPoolSize int, reqPerSec int) *PClient {
	var semaphore chan int = nil
	if maxPoolSize > 0 {
		semaphore = make(chan int, maxPoolSize) // Buffered channel to act as a semaphore
	}

	var emitter <-chan time.Time = nil
	if reqPerSec > 0 {
		emitter = time.NewTicker(time.Second / time.Duration(reqPerSec)).C // x req/s == 1s/x req (inverse)
	}

	return &PClient{
		client:       stdClient,
		maxPoolSize:  maxPoolSize,
		cSemaphore:   semaphore,
		reqPerSecond: reqPerSec,
		rateLimiter:  emitter,
	}
}
// NewPClient returns a *PClient that wraps an *http.Client and sets the
// maximum pool size as well as the requests per second as integers.
//
// A zero for maxPoolSize will set no limit
// A zero for reqPerSec will set no limit
NewPClient returns a *PClient that wraps an *http.Client and sets the
maximum pool size as well as the requests per second as integers.

A zero for maxPoolSize will set no limit
A zero for reqPerSec will set no limit
// NewPClient returns a * PClient that wraps an * http . Client and sets the // maximum pool size as well as the requests per second as integers . // // A zero for maxPoolSize will set no limit // A zero for reqPerSec will set no limit
func NewPClient(stdClient *http.Client, maxPoolSize int, reqPerSec int) *PClient {
	var semaphore chan int = nil
	if maxPoolSize > 0 {
		semaphore = make(chan int, maxPoolSize) 
	}
	var emitter <-chan time.Time = nil
	if reqPerSec > 0 {
		emitter = time.NewTicker(time.Second / time.Duration(reqPerSec)).C 
	}
	return &PClient{
		client:       stdClient,
		maxPoolSize:  maxPoolSize,
		cSemaphore:   semaphore,
		reqPerSecond: reqPerSec,
		rateLimiter:  emitter,
	}
}
func NewPClient ( stdClient * http . Client , maxPoolSize int , reqPerSec int ) * PClient { var semaphore chan int = nil if maxPoolSize > 0 { semaphore = make ( chan int , maxPoolSize ) } var emitter <- chan time . Time = nil if reqPerSec > 0 { emitter = time . NewTicker ( time . Second / time . Duration ( reqPerSec ) ) . C } return & PClient { client : stdClient , maxPoolSize : maxPoolSize , cSemaphore : semaphore , reqPerSecond : reqPerSec , rateLimiter : emitter , } }
NewPClient returns a *PClient that wraps an *http.Client and sets the
maximum pool size as well as the requests per second as integers.
NewPClient returns a * PClient that wraps an * http . Client and sets the maximum pool size as well as the requests per second as integers .
// Buffered channel to act as a semaphore // x req/s == 1s/x req (inverse)