func NewThrottling(concurrency uint, coolDown time.Duration, maxQueue uint, queueFullError error) *Throttling {
	t := &Throttling{
		concurrency:    concurrency,
		coolDown:       coolDown,
		stack:          make(chan func(), maxQueue),
		maxQueue:       maxQueue,
		queueFullError: queueFullError,
	}
	inWorkChan := make(chan chan uint)
	incInWork := make(chan struct{})
	decInWork := make(chan struct{})
	go func() {
		var inWork uint
		for {
			if t.stack == nil {
				return
			}
			select {
			case respChan := <-inWorkChan:
				respChan <- inWork
			case <-incInWork:
				inWork++
			case <-decInWork:
				if inWork == 0 {
					continue
				}
				inWork--
			}
		}
	}()
	go func() {
		for {
			if t.stack == nil {
				return
			}
			iw := make(chan uint)
			inWorkChan <- iw
			if <-iw >= t.concurrency {
				time.Sleep(time.Second)
				continue
			}
			select {
			case job := <-t.stack:
				incInWork <- struct{}{}
				go job()
				go func() {
					<-time.After(t.coolDown)
					decInWork <- struct{}{}
				}()
			}
		}
	}()
	return t
}
create new throttling request limitation
package request_limitation
import (
	"time"
)
type Throttling struct {
	concurrency    uint
	coolDown       time.Duration
	stack          chan func()
	maxQueue       uint
	queueFullError error
}
func (t *Throttling) Close() error {
	close(t.stack)
	return nil
}