forked from vitessio/vitess
/
module.go
21 lines (18 loc) · 816 Bytes
/
module.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Copyright 2016, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package throttler
// Module specifies the API for a Decision Module which can tell the throttler
// to dynamically increase or decrease the current rate limit.
type Module interface {
// Start can be implemented to e.g. start own Go routines and initialize the
// module.
// rateUpdateChan must be used to notify the Throttler when the module's
// maximum rate limit has changed and a subsequent MaxRate() call would return
// a different value.
Start(rateUpdateChan chan<- struct{})
// Stop will free all resources and be called by Throttler.Close().
Stop()
// MaxRate returns the maximum allowed rate determined by the module.
MaxRate() int64
}