apiserver: move LongRunningRequestCheck type into endpoints/request

Kubernetes-commit: c1bf6e832e2887ef6cd0e7b7fa97a168fdf474e5
This commit is contained in:
Dr. Stefan Schimanski 2017-05-23 11:19:30 +02:00 committed by Kubernetes Publisher
parent 1d0b329280
commit 6bd3c73150
5 changed files with 7 additions and 7 deletions

View File

@ -24,6 +24,9 @@ import (
"github.com/golang/glog" "github.com/golang/glog"
) )
// LongRunningRequestCheck is a predicate which is true for long-running http requests.
type LongRunningRequestCheck func(r *http.Request, requestInfo *RequestInfo) bool
// RequestContextMapper keeps track of the context associated with a particular request // RequestContextMapper keeps track of the context associated with a particular request
type RequestContextMapper interface { type RequestContextMapper interface {
// Get returns the context associated with the given request (if any), and true if the request has an associated context, and false if it does not. // Get returns the context associated with the given request (if any), and true if the request has an associated context, and false if it does not.

View File

@ -150,7 +150,7 @@ type Config struct {
// request has to wait. // request has to wait.
MaxMutatingRequestsInFlight int MaxMutatingRequestsInFlight int
// Predicate which is true for paths of long-running http requests // Predicate which is true for paths of long-running http requests
LongRunningFunc genericfilters.LongRunningRequestCheck LongRunningFunc apirequest.LongRunningRequestCheck
//=========================================================================== //===========================================================================
// values below here are targets for removal // values below here are targets for removal

View File

@ -23,11 +23,8 @@ import (
apirequest "k8s.io/apiserver/pkg/endpoints/request" apirequest "k8s.io/apiserver/pkg/endpoints/request"
) )
// LongRunningRequestCheck is a predicate which is true for long-running http requests.
type LongRunningRequestCheck func(r *http.Request, requestInfo *apirequest.RequestInfo) bool
// BasicLongRunningRequestCheck returns true if the given request has one of the specified verbs or one of the specified subresources // BasicLongRunningRequestCheck returns true if the given request has one of the specified verbs or one of the specified subresources
func BasicLongRunningRequestCheck(longRunningVerbs, longRunningSubresources sets.String) LongRunningRequestCheck { func BasicLongRunningRequestCheck(longRunningVerbs, longRunningSubresources sets.String) apirequest.LongRunningRequestCheck {
return func(r *http.Request, requestInfo *apirequest.RequestInfo) bool { return func(r *http.Request, requestInfo *apirequest.RequestInfo) bool {
if longRunningVerbs.Has(requestInfo.Verb) { if longRunningVerbs.Has(requestInfo.Verb) {
return true return true

View File

@ -47,7 +47,7 @@ func WithMaxInFlightLimit(
nonMutatingLimit int, nonMutatingLimit int,
mutatingLimit int, mutatingLimit int,
requestContextMapper genericapirequest.RequestContextMapper, requestContextMapper genericapirequest.RequestContextMapper,
longRunningRequestCheck LongRunningRequestCheck, longRunningRequestCheck apirequest.LongRunningRequestCheck,
) http.Handler { ) http.Handler {
if nonMutatingLimit == 0 && mutatingLimit == 0 { if nonMutatingLimit == 0 && mutatingLimit == 0 {
return handler return handler

View File

@ -35,7 +35,7 @@ const globalTimeout = time.Minute
var errConnKilled = fmt.Errorf("kill connection/stream") var errConnKilled = fmt.Errorf("kill connection/stream")
// WithTimeoutForNonLongRunningRequests times out non-long-running requests after the time given by globalTimeout. // WithTimeoutForNonLongRunningRequests times out non-long-running requests after the time given by globalTimeout.
func WithTimeoutForNonLongRunningRequests(handler http.Handler, requestContextMapper apirequest.RequestContextMapper, longRunning LongRunningRequestCheck) http.Handler { func WithTimeoutForNonLongRunningRequests(handler http.Handler, requestContextMapper apirequest.RequestContextMapper, longRunning apirequest.LongRunningRequestCheck) http.Handler {
if longRunning == nil { if longRunning == nil {
return handler return handler
} }