func (q *Queue) Try(next http.HandlerFunc) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		_, noWait := r.Header["X-Selenoid-No-Wait"]
		select {
		case q.limit <- struct{}{}:
			<-q.limit
		default:
			if noWait {
				util.JsonError(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests)
				return
			}
		}
		next.ServeHTTP(w, r)
	}
}
Try - when X-Selenoid-No-Wait header is set
reply to client immediately if queue is full
package protect
import (
	"log"
	"math"
	"net/http"
	"time"
	"github.com/aerokube/util"
)
type Queue struct {
	disabled bool
	limit    chan struct{}
	queued   chan struct{}
	pending  chan struct{}
	used     chan struct{}
}