package mysqlqm

import "github.com/google/trillian/quota/mysqlqm"

Package mysqlqm defines a MySQL-based quota.Manager implementation.

Index

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.

)
const QuotaManagerName = "mysql"

QuotaManagerName identifies the MySQL quota implementation.

Variables

var ErrTooManyUnsequencedRows = errors.New("too many unsequenced rows")

ErrTooManyUnsequencedRows is returned when tokens are requested but Unsequenced has grown beyond the configured limit.

Types

type QuotaManager

type QuotaManager struct {
	DB                 *sql.DB
	MaxUnsequencedRows int
	UseSelectCount     bool
}

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

func (m *QuotaManager) GetTokens(ctx context.Context, numTokens int, specs []quota.Spec) error

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) PutTokens

func (m *QuotaManager) PutTokens(ctx context.Context, numTokens int, specs []quota.Spec) error

PutTokens implements quota.Manager.PutTokens. It's a noop for QuotaManager.

func (*QuotaManager) ResetQuota

func (m *QuotaManager) ResetQuota(ctx context.Context, specs []quota.Spec) error

ResetQuota implements quota.Manager.ResetQuota. It's a noop for QuotaManager.

Source Files

mysql_quota.go quota_provider.go

Version
v1.7.1 (latest)
Published
Jan 9, 2025
Platform
linux/amd64
Imports
8 packages
Last checked
5 days ago

Tools for package owners.