limit

package
v0.24.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB implements the Store interface against a Postgres DB.

func NewDB

func NewDB(ctx context.Context, db *sql.DB) (*DB, error)

NewDB creates a new DB and prepares all necessary SQL statements.

func (*DB) All

func (db *DB) All(ctx context.Context) (Limits, error)

All implements the Store interface.

func (*DB) Max

func (db *DB) Max(ctx context.Context, id ID) (int, error)

Max implements the Store interface.

func (*DB) ResetAll

func (db *DB) ResetAll(ctx context.Context) error

ResetAll implements the Store interface.

func (*DB) SetMax

func (db *DB) SetMax(ctx context.Context, id ID, max int) error

SetMax implements the Store interface.

type ID

type ID string

ID represents the identifier for a given system limit.

const (
	NotificationRulesPerUser    ID = "notification_rules_per_user"
	ContactMethodsPerUser       ID = "contact_methods_per_user"
	EPStepsPerPolicy            ID = "ep_steps_per_policy"
	EPActionsPerStep            ID = "ep_actions_per_step"
	ParticipantsPerRotation     ID = "participants_per_rotation"
	RulesPerSchedule            ID = "rules_per_schedule"
	IntegrationKeysPerService   ID = "integration_keys_per_service"
	UnackedAlertsPerService     ID = "unacked_alerts_per_service"
	TargetsPerSchedule          ID = "targets_per_schedule"
	HeartbeatMonitorsPerService ID = "heartbeat_monitors_per_service"
	UserOverridesPerSchedule    ID = "user_overrides_per_schedule"
)

IDs of configurable limits.

func (ID) Valid

func (id ID) Valid() error

Valid returns nil if a given ID is valid, a validation error is returned otherwise.

type Limits

type Limits map[ID]int

Limits contains the current value of all configurable limits.

func (Limits) Max

func (l Limits) Max(id ID) int

Max returns the current max value of the limit with the given ID.

type Store

type Store interface {
	// ResetAll will reset all configurable limits to the default (no-limit).
	ResetAll(context.Context) error

	// Max will return the current max value for the given limit.
	Max(context.Context, ID) (int, error)

	// SetMax allows setting the max value for a limit.
	SetMax(context.Context, ID, int) error

	// All will get the current value of all limits.
	All(context.Context) (Limits, error)
}

A Store allows getting and setting system limits.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL