Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrNoDevice = errors.New("no device found")
)
Functions ¶
This section is empty.
Types ¶
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) 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.
Click to show internal directories.
Click to hide internal directories.