mirror of
https://github.com/openziti/zrok.git
synced 2025-02-01 19:10:05 +01:00
fully remove share mode from scope concept; add performance indexes (#606)
This commit is contained in:
parent
a389674d51
commit
79053e1b28
@ -36,7 +36,6 @@ type BandwidthClass interface {
|
||||
|
||||
type LimitClass struct {
|
||||
Model
|
||||
ShareMode *sdk.ShareMode
|
||||
BackendMode *sdk.BackendMode
|
||||
Environments int
|
||||
Shares int
|
||||
@ -77,13 +76,6 @@ func (lc LimitClass) GetUniqueNames() int {
|
||||
return lc.UniqueNames
|
||||
}
|
||||
|
||||
func (lc LimitClass) GetShareMode() sdk.ShareMode {
|
||||
if lc.ShareMode == nil {
|
||||
return ""
|
||||
}
|
||||
return *lc.ShareMode
|
||||
}
|
||||
|
||||
func (lc LimitClass) GetBackendMode() sdk.BackendMode {
|
||||
if lc.BackendMode == nil {
|
||||
return ""
|
||||
@ -113,9 +105,6 @@ func (lc LimitClass) GetLimitAction() LimitAction {
|
||||
|
||||
func (lc LimitClass) String() string {
|
||||
out := fmt.Sprintf("LimitClass<id: %d", lc.Id)
|
||||
if lc.ShareMode != nil {
|
||||
out += fmt.Sprintf(", shareMode: '%s'", *lc.ShareMode)
|
||||
}
|
||||
if lc.BackendMode != nil {
|
||||
out += fmt.Sprintf(", backendMode: '%s'", *lc.BackendMode)
|
||||
}
|
||||
@ -150,12 +139,12 @@ func (lc LimitClass) String() string {
|
||||
var _ BandwidthClass = (*LimitClass)(nil)
|
||||
|
||||
func (str *Store) CreateLimitClass(lc *LimitClass, trx *sqlx.Tx) (int, error) {
|
||||
stmt, err := trx.Prepare("insert into limit_classes (share_mode, backend_mode, environments, shares, reserved_shares, unique_names, period_minutes, rx_bytes, tx_bytes, total_bytes, limit_action) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) returning id")
|
||||
stmt, err := trx.Prepare("insert into limit_classes (backend_mode, environments, shares, reserved_shares, unique_names, period_minutes, rx_bytes, tx_bytes, total_bytes, limit_action) values ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) returning id")
|
||||
if err != nil {
|
||||
return 0, errors.Wrap(err, "error preparing limit_classes insert statement")
|
||||
}
|
||||
var id int
|
||||
if err := stmt.QueryRow(lc.ShareMode, lc.BackendMode, lc.Environments, lc.Shares, lc.ReservedShares, lc.UniqueNames, lc.PeriodMinutes, lc.RxBytes, lc.TxBytes, lc.TotalBytes, lc.LimitAction).Scan(&id); err != nil {
|
||||
if err := stmt.QueryRow(lc.BackendMode, lc.Environments, lc.Shares, lc.ReservedShares, lc.UniqueNames, lc.PeriodMinutes, lc.RxBytes, lc.TxBytes, lc.TotalBytes, lc.LimitAction).Scan(&id); err != nil {
|
||||
return 0, errors.Wrap(err, "error executing limit_classes insert statement")
|
||||
}
|
||||
return id, nil
|
||||
|
@ -5,7 +5,6 @@ create type limit_action as enum ('warning', 'limit');
|
||||
create table limit_classes (
|
||||
id serial primary key,
|
||||
|
||||
share_mode share_mode,
|
||||
backend_mode backend_mode,
|
||||
|
||||
environments int not null default (-1),
|
||||
@ -31,4 +30,7 @@ create table applied_limit_classes (
|
||||
created_at timestamptz not null default(current_timestamp),
|
||||
updated_at timestamptz not null default(current_timestamp),
|
||||
deleted boolean not null default(false)
|
||||
);
|
||||
);
|
||||
|
||||
create index applied_limit_classes_account_id_idx on applied_limit_classes (account_id);
|
||||
create index applied_limit_classes_limit_class_id_idx on applied_limit_classes (limit_class_id);
|
@ -3,7 +3,6 @@
|
||||
create table limit_classes (
|
||||
id integer primary key,
|
||||
|
||||
share_mode string,
|
||||
backend_mode string,
|
||||
|
||||
environments integer not null default (-1),
|
||||
@ -29,4 +28,7 @@ create table applied_limit_classes (
|
||||
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
|
||||
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
|
||||
deleted boolean not null default(false)
|
||||
);
|
||||
);
|
||||
|
||||
create index applied_limit_classes_account_id_idx on applied_limit_classes (account_id);
|
||||
create index applied_limit_classes_limit_class_id_idx on applied_limit_classes (limit_class_id);
|
Loading…
Reference in New Issue
Block a user