middleware

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package middleware provides common middleware and decorators for WebPA and XMiDT servers

Index

Constants

View Source
const DefaultTimeout = 30 * time.Second

Variables

This section is empty.

Functions

func Busy

func Busy(maxClients int64, busyError error) endpoint.Middleware

Busy produces a middleware that returns an error if the maximum number of clients is reached. If busyError is specified, that is returned. Otherwise, a default error is returned.

If maxClients is nonpositive, this factory function panics

func Concurrent

func Concurrent(concurrency int, timeoutError error) endpoint.Middleware

Concurrent produces a middleware that allows only a set number of concurrent calls via a semaphore implemented as a buffered channel. The context is used for cancellation, and if the context is cancelled then timeoutError is returned if it is not nil, ctx.Err() otherwise.

func Logging

func Logging(next endpoint.Endpoint) endpoint.Endpoint

Logging is a go-kit middleware that inserts any associated logger from requests into the context. Requests that do not provide a Logger() log.Logger method are simply ignored.

This middleware is primarily useful because go-kit does not allow you to alter the context when requests are decoded. That means that any contextual logger created when the request was decoded isn't visible in the context, unless something like this middleware is used.

func Timeout

func Timeout(timeout time.Duration) endpoint.Middleware

Timeout applies the given timeout to all WRP Requests. The context's cancellation function is always called.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL