Documentation ¶
Overview ¶
Package queue provides components for the queue-proxy binary.
Index ¶
- Constants
- Variables
- func ForwardedShimHandler(h http.Handler) http.Handler
- func GetRouteTagNameFromRequest(r *http.Request) string
- func NewAppRequestMetricsHandler(next http.Handler, b *Breaker, ns, service, config, rev, pod string) (http.Handler, error)
- func NewRequestMetricsHandler(next http.Handler, ns, service, config, rev, pod string) (http.Handler, error)
- func NewStatsHandler(proto http.Handler) http.Handler
- func ProxyHandler(breaker *Breaker, stats *netstats.RequestStats, tracingEnabled bool, ...) http.HandlerFunc
- type Breaker
- type BreakerParams
- type ProtobufStatsReporter
Constants ¶
const ( // Name is the name of the component. Name = "queue" // RequestQueueDrainPath specifies the path to wait until the proxy // server is shut down. Any subsequent calls to this endpoint after // the server has finished shutting down it will return immediately. // Main usage is to delay the termination of user-container until all // accepted requests have been processed. RequestQueueDrainPath = "/wait-for-drain" // CertDirectory is the name of the directory path where certificates are stored. CertDirectory = "/var/lib/knative/certs" // PodInfoDirectory is the name of the directory path where podinfo are stored. PodInfoDirectory = "/etc/podinfo" // TokenDirectory is the name of the directory path where tokens are stored. TokenDirectory = "/var/run/secrets/tokens" // PodInfoAnnotationsFilename is the file name of the annotations in PodInfoDirectory. PodInfoAnnotationsFilename = "annotations" )
const MaxBreakerCapacity = math.MaxInt32
MaxBreakerCapacity is the largest valid value for the MaxConcurrency value of BreakerParams. This is limited by the maximum size of a chan struct{} in the current implementation.
Variables ¶
var ( // ErrRequestQueueFull indicates the breaker queue depth was exceeded. ErrRequestQueueFull = errors.New("pending request queue full") )
Functions ¶
func ForwardedShimHandler ¶ added in v0.7.0
ForwardedShimHandler attempts to shim a `forwarded` HTTP header from the information available in the `x-forwarded-*` headers. When available, each node in the `x-forwarded-for` header is combined with the `x-forwarded-proto` and `x-forwarded-host` fields to construct a `forwarded` header. The `x-forwarded-by` header is ignored entirely, since it cannot be reliably combined with `x-forwarded-for`. No-op if a `forwarded` header is already present.
func GetRouteTagNameFromRequest ¶ added in v0.24.0
GetRouteTagNameFromRequest extracts the value of the tag header from http.Request
func NewAppRequestMetricsHandler ¶ added in v0.13.0
func NewAppRequestMetricsHandler(next http.Handler, b *Breaker, ns, service, config, rev, pod string) (http.Handler, error)
NewAppRequestMetricsHandler creates an http.Handler that emits request metrics.
func NewRequestMetricsHandler ¶ added in v0.13.0
func NewRequestMetricsHandler(next http.Handler, ns, service, config, rev, pod string) (http.Handler, error)
NewRequestMetricsHandler creates an http.Handler that emits request metrics.
func NewStatsHandler ¶ added in v0.17.0
NewStatsHandler returns a new StatHandler.
func ProxyHandler ¶ added in v0.18.0
func ProxyHandler(breaker *Breaker, stats *netstats.RequestStats, tracingEnabled bool, next http.Handler) http.HandlerFunc
ProxyHandler sends requests to the `next` handler at a rate controlled by the passed `breaker`, while recording stats to `stats`.
Types ¶
type Breaker ¶
type Breaker struct {
// contains filtered or unexported fields
}
Breaker is a component that enforces a concurrency limit on the execution of a function. It also maintains a queue of function executions in excess of the concurrency limit. Function call attempts beyond the limit of the queue are failed immediately.
func NewBreaker ¶
func NewBreaker(params BreakerParams) *Breaker
NewBreaker creates a Breaker with the desired queue depth, concurrency limit and initial capacity.
func (*Breaker) Capacity ¶ added in v0.4.0
Capacity returns the number of allowed in-flight requests on this breaker.
func (*Breaker) InFlight ¶ added in v0.9.0
InFlight returns the number of requests currently in flight in this breaker.
func (*Breaker) Maybe ¶
Maybe conditionally executes thunk based on the Breaker concurrency and queue parameters. If the concurrency limit and queue capacity are already consumed, Maybe returns immediately without calling thunk. If the thunk was executed, Maybe returns nil, else error.
func (*Breaker) Reserve ¶ added in v0.11.0
Reserve reserves an execution slot in the breaker, to permit richer semantics in the caller. The caller on success must execute the callback when done with work.
func (*Breaker) UpdateConcurrency ¶ added in v0.4.0
UpdateConcurrency updates the maximum number of in-flight requests.
type BreakerParams ¶ added in v0.4.0
BreakerParams defines the parameters of the breaker.
type ProtobufStatsReporter ¶ added in v0.17.0
type ProtobufStatsReporter struct {
// contains filtered or unexported fields
}
ProtobufStatsReporter structure represents a protobuf stats reporter.
func NewProtobufStatsReporter ¶ added in v0.17.0
func NewProtobufStatsReporter(pod string, reportingPeriod time.Duration) *ProtobufStatsReporter
NewProtobufStatsReporter creates a reporter that collects and reports queue metrics.
func (*ProtobufStatsReporter) Report ¶ added in v0.17.0
func (r *ProtobufStatsReporter) Report(stats netstats.RequestStatsReport)
Report captures request metrics.
func (*ProtobufStatsReporter) ServeHTTP ¶ added in v0.17.0
func (r *ProtobufStatsReporter) ServeHTTP(w http.ResponseWriter, _ *http.Request)
ServeHTTP serves the stats in protobuf format over HTTP.