Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoDevice is returned when device is empty or not found in procfs. ErrNoDevice = errors.New("no device found") )
Functions ¶
func GetMonitoring ¶ added in v0.15.0
GetMonitoring attempts to extract the monitoring value from the given context.
Types ¶
type Controller ¶ added in v0.15.0
Controller is the interface that all access control types should implement.
type TokenController ¶ added in v0.15.0
type TokenController struct {
// contains filtered or unexported fields
}
TokenController manages access control for clients providing access_token parameters.
func NewTokenController ¶ added in v0.15.0
func NewTokenController(name string, verifier Verifier) *TokenController
NewTokenController creates a new token controller.
type TxController ¶
type TxController struct {
// contains filtered or unexported fields
}
TxController calculates the bytes transmitted every period from the named device.
func NewTxController ¶
func NewTxController(rate uint64) (*TxController, error)
NewTxController creates a new instance initialized to run every second. Caller should run Watch in a goroutine to regularly update the current rate.
func (*TxController) Accept ¶ added in v0.14.2
Accept wraps the call to listener's Accept. If the TxController is limited, then Accept immediately closes the connection and returns an error.
func (*TxController) Current ¶ added in v0.14.2
func (tx *TxController) Current() uint64
Current exports the current rate. Useful for diagnostics.
func (*TxController) Limit ¶
func (tx *TxController) Limit(next http.Handler) http.Handler
Limit enforces that the TxController rate limit is respected before running the next handler. If the rate is unspecified (zero), all requests are accepted.
func (*TxController) Watch ¶
func (tx *TxController) Watch(ctx context.Context) error
Watch updates the current rate every period. If the context is cancelled, the context error is returned. If the TxController rate is zero, Watch returns immediately. Callers should typically run Watch in a goroutine.