Documentation ¶
Overview ¶
Package mysqlqm defines a MySQL-based quota.Manager implementation.
Index ¶
- Constants
- Variables
- type QuotaManager
- func (m *QuotaManager) GetTokens(ctx context.Context, numTokens int, specs []quota.Spec) error
- func (m *QuotaManager) GetUser(ctx context.Context, req interface{}) string
- func (m *QuotaManager) PeekTokens(ctx context.Context, specs []quota.Spec) (map[quota.Spec]int, error)
- func (m *QuotaManager) PutTokens(ctx context.Context, numTokens int, specs []quota.Spec) error
- func (m *QuotaManager) ResetQuota(ctx context.Context, specs []quota.Spec) error
Constants ¶
const ( // DefaultMaxUnsequenced is a suggested value for MaxUnsequencedRows. // Note that this is a Global/Write quota suggestion, so it applies across trees. DefaultMaxUnsequenced = 500000 // About 2h of non-stop signing at 70QPS. )
Variables ¶
var ( // ErrTooManyUnsequencedRows is returned when tokens are requested but Unsequenced has grown // beyond the configured limit. ErrTooManyUnsequencedRows = errors.New("too many unsequenced rows") )
Functions ¶
This section is empty.
Types ¶
type QuotaManager ¶
QuotaManager is a MySQL-based quota.Manager implementation.
It has two working modes: one queries the information schema for the number of Unsequenced rows, the other does a select count(*) on the Unsequenced table. Information schema queries are default, even though they are approximate, as they're constant time (select count(*) on InnoDB based MySQL needs to traverse the index and may take quite a while to complete).
QuotaManager only implements Global/Write quotas, which is based on the number of Unsequenced rows (to be exact, tokens = MaxUnsequencedRows - actualUnsequencedRows). Other quotas are considered infinite.
func (*QuotaManager) GetTokens ¶
GetTokens implements quota.Manager.GetTokens. It doesn't actually reserve or retrieve tokens, instead it allows access based on the number of rows in the Unsequenced table.
func (*QuotaManager) GetUser ¶
func (m *QuotaManager) GetUser(ctx context.Context, req interface{}) string
GetUser implements quota.Manager.GetUser. User quotas are not implemented by QuotaManager.
func (*QuotaManager) PeekTokens ¶
func (m *QuotaManager) PeekTokens(ctx context.Context, specs []quota.Spec) (map[quota.Spec]int, error)
PeekTokens implements quota.Manager.PeekTokens. Global/Write tokens reflect the number of rows in the Unsequenced tables, other specs are considered infinite.
func (*QuotaManager) PutTokens ¶
PutTokens implements quota.Manager.PutTokens. It's a noop for QuotaManager.
func (*QuotaManager) ResetQuota ¶
ResetQuota implements quota.Manager.ResetQuota. It's a noop for QuotaManager.