mirror of
https://github.com/openziti/zrok.git
synced 2024-11-26 01:54:09 +01:00
include rx|tx byte counts in limits journals (#273)
This commit is contained in:
parent
0fa682e764
commit
b69237e9cc
@ -8,16 +8,18 @@ import (
|
|||||||
type AccountLimitJournal struct {
|
type AccountLimitJournal struct {
|
||||||
Model
|
Model
|
||||||
AccountId int
|
AccountId int
|
||||||
|
RxBytes int64
|
||||||
|
TxBytes int64
|
||||||
Action string
|
Action string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Store) CreateAccountLimitJournal(j *AccountLimitJournal, tx *sqlx.Tx) (int, error) {
|
func (self *Store) CreateAccountLimitJournal(j *AccountLimitJournal, tx *sqlx.Tx) (int, error) {
|
||||||
stmt, err := tx.Prepare("insert into account_limit_journal (account_id, action) values ($1, $2) returning id")
|
stmt, err := tx.Prepare("insert into account_limit_journal (account_id, rx_bytes, tx_bytes, action) values ($1, $2, $3, $4) returning id")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, errors.Wrap(err, "error preparing account_limit_journal insert statement")
|
return 0, errors.Wrap(err, "error preparing account_limit_journal insert statement")
|
||||||
}
|
}
|
||||||
var id int
|
var id int
|
||||||
if err := stmt.QueryRow(j.AccountId, j.AccountId).Scan(&id); err != nil {
|
if err := stmt.QueryRow(j.AccountId, j.RxBytes, j.TxBytes, j.AccountId).Scan(&id); err != nil {
|
||||||
return 0, errors.Wrap(err, "error executing account_limit_journal insert statement")
|
return 0, errors.Wrap(err, "error executing account_limit_journal insert statement")
|
||||||
}
|
}
|
||||||
return id, nil
|
return id, nil
|
||||||
|
@ -8,16 +8,18 @@ import (
|
|||||||
type EnvironmentLimitJournal struct {
|
type EnvironmentLimitJournal struct {
|
||||||
Model
|
Model
|
||||||
EnvironmentId int
|
EnvironmentId int
|
||||||
|
RxBytes int64
|
||||||
|
TxBytes int64
|
||||||
Action string
|
Action string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Store) CreateEnvironmentLimitJournal(j *EnvironmentLimitJournal, tx *sqlx.Tx) (int, error) {
|
func (self *Store) CreateEnvironmentLimitJournal(j *EnvironmentLimitJournal, tx *sqlx.Tx) (int, error) {
|
||||||
stmt, err := tx.Prepare("insert into environment_limit_journal (environment_id, action) values ($1, $2) returning id")
|
stmt, err := tx.Prepare("insert into environment_limit_journal (environment_id, rx_bytes, tx_bytes, action) values ($1, $2, $3, $4) returning id")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, errors.Wrap(err, "error preparing environment_limit_journal insert statement")
|
return 0, errors.Wrap(err, "error preparing environment_limit_journal insert statement")
|
||||||
}
|
}
|
||||||
var id int
|
var id int
|
||||||
if err := stmt.QueryRow(j.EnvironmentId, j.Action).Scan(&id); err != nil {
|
if err := stmt.QueryRow(j.EnvironmentId, j.RxBytes, j.TxBytes, j.Action).Scan(&id); err != nil {
|
||||||
return 0, errors.Wrap(err, "error executing environment_limit_journal insert statement")
|
return 0, errors.Wrap(err, "error executing environment_limit_journal insert statement")
|
||||||
}
|
}
|
||||||
return id, nil
|
return id, nil
|
||||||
|
@ -8,16 +8,18 @@ import (
|
|||||||
type ShareLimitJournal struct {
|
type ShareLimitJournal struct {
|
||||||
Model
|
Model
|
||||||
ShareId int
|
ShareId int
|
||||||
|
RxBytes int64
|
||||||
|
TxBytes int64
|
||||||
Action string
|
Action string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Store) CreateShareLimitJournal(j *ShareLimitJournal, tx *sqlx.Tx) (int, error) {
|
func (self *Store) CreateShareLimitJournal(j *ShareLimitJournal, tx *sqlx.Tx) (int, error) {
|
||||||
stmt, err := tx.Prepare("insert into share_limit_journal (share_id, action) values ($1, $2) returning id")
|
stmt, err := tx.Prepare("insert into share_limit_journal (share_id, rx_bytes, tx_bytes, action) values ($1, $2, $3, $4) returning id")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, errors.Wrap(err, "error preparing share_limit_journal insert statement")
|
return 0, errors.Wrap(err, "error preparing share_limit_journal insert statement")
|
||||||
}
|
}
|
||||||
var id int
|
var id int
|
||||||
if err := stmt.QueryRow(j.ShareId, j.Action).Scan(&id); err != nil {
|
if err := stmt.QueryRow(j.ShareId, j.RxBytes, j.TxBytes, j.Action).Scan(&id); err != nil {
|
||||||
return 0, errors.Wrap(err, "error executing share_limit_journal insert statement")
|
return 0, errors.Wrap(err, "error executing share_limit_journal insert statement")
|
||||||
}
|
}
|
||||||
return id, nil
|
return id, nil
|
||||||
|
@ -5,6 +5,8 @@ create type limit_action_type as enum ('clear', 'warning', 'limit');
|
|||||||
create table account_limit_journal (
|
create table account_limit_journal (
|
||||||
id serial primary key,
|
id serial primary key,
|
||||||
account_id integer references accounts(id),
|
account_id integer references accounts(id),
|
||||||
|
rx_bytes bigint not null,
|
||||||
|
tx_bytes bigint not null,
|
||||||
action limit_action_type not null,
|
action limit_action_type not null,
|
||||||
created_at timestamptz not null default(current_timestamp),
|
created_at timestamptz not null default(current_timestamp),
|
||||||
updated_at timestamptz not null default(current_timestamp)
|
updated_at timestamptz not null default(current_timestamp)
|
||||||
@ -13,6 +15,8 @@ create table account_limit_journal (
|
|||||||
create table environment_limit_journal (
|
create table environment_limit_journal (
|
||||||
id serial primary key,
|
id serial primary key,
|
||||||
environment_id integer references environments(id),
|
environment_id integer references environments(id),
|
||||||
|
rx_bytes bigint not null,
|
||||||
|
tx_bytes bigint not null,
|
||||||
action limit_action_type not null,
|
action limit_action_type not null,
|
||||||
created_at timestamptz not null default(current_timestamp),
|
created_at timestamptz not null default(current_timestamp),
|
||||||
updated_at timestamptz not null default(current_timestamp)
|
updated_at timestamptz not null default(current_timestamp)
|
||||||
@ -21,6 +25,8 @@ create table environment_limit_journal (
|
|||||||
create table share_limit_journal (
|
create table share_limit_journal (
|
||||||
id serial primary key,
|
id serial primary key,
|
||||||
share_id integer references shares(id),
|
share_id integer references shares(id),
|
||||||
|
rx_bytes bigint not null,
|
||||||
|
tx_bytes bigint not null,
|
||||||
action limit_action_type not null,
|
action limit_action_type not null,
|
||||||
created_at timestamptz not null default(current_timestamp),
|
created_at timestamptz not null default(current_timestamp),
|
||||||
updated_at timestamptz not null default(current_timestamp)
|
updated_at timestamptz not null default(current_timestamp)
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
create table account_limit_journal (
|
create table account_limit_journal (
|
||||||
id serial primary key,
|
id serial primary key,
|
||||||
account_id integer references accounts(id),
|
account_id integer references accounts(id),
|
||||||
|
rx_bytes bigint not null,
|
||||||
|
tx_bytes bigint not null,
|
||||||
action limit_action_type not null,
|
action limit_action_type not null,
|
||||||
created_at timestamptz not null default(current_timestamp),
|
created_at timestamptz not null default(current_timestamp),
|
||||||
updated_at timestamptz not null default(current_timestamp)
|
updated_at timestamptz not null default(current_timestamp)
|
||||||
@ -11,6 +13,8 @@ create table account_limit_journal (
|
|||||||
create table environment_limit_journal (
|
create table environment_limit_journal (
|
||||||
id serial primary key,
|
id serial primary key,
|
||||||
environment_id integer references environments(id),
|
environment_id integer references environments(id),
|
||||||
|
rx_bytes bigint not null,
|
||||||
|
tx_bytes bigint not null,
|
||||||
action limit_action_type not null,
|
action limit_action_type not null,
|
||||||
created_at timestamptz not null default(current_timestamp),
|
created_at timestamptz not null default(current_timestamp),
|
||||||
updated_at timestamptz not null default(current_timestamp)
|
updated_at timestamptz not null default(current_timestamp)
|
||||||
@ -19,6 +23,8 @@ create table environment_limit_journal (
|
|||||||
create table share_limit_journal (
|
create table share_limit_journal (
|
||||||
id serial primary key,
|
id serial primary key,
|
||||||
share_id integer references shares(id),
|
share_id integer references shares(id),
|
||||||
|
rx_bytes bigint not null,
|
||||||
|
tx_bytes bigint not null,
|
||||||
action limit_action_type not null,
|
action limit_action_type not null,
|
||||||
created_at timestamptz not null default(current_timestamp),
|
created_at timestamptz not null default(current_timestamp),
|
||||||
updated_at timestamptz not null default(current_timestamp)
|
updated_at timestamptz not null default(current_timestamp)
|
||||||
|
Loading…
Reference in New Issue
Block a user