Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3456 Golang changes #255

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions services/settings/quota/types_quota.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package quota

import (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of adding new structures for all of these, we can reuse the policy manager object structures:

this will simplify policy manager integration as well

"time"
)

type QuotaConditions struct {
Type string `json:"type"`
Op string `json:"op"`
Value string `json:"value"`
Proto string `json:"proto"`
}

type QuotaExceedActions struct {
ID string `json:"id"`
Name string `json:name`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo - need double quotes around name

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

....still

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @AlistairJohnParker , This code is no more used. We have moved this module to sync settings. Will talk to John S and invalidate this branch. Please ignore this for now. Thanks for the review.

Description string `json:description`
Action string `json:action`
Priority string `json:priroity`
Default bool `json:enabled`
}

type QuotaAction struct {
Type string `json:"type"`
QuotaID string `json:"quota_id"`
ExceedActionID string `json:"exceed_action_id"`
}

type QuotaConfiguration struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Period string `json:"period"`
DataSize string `json:"datasize"`
}

type QuotaRules struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Conditions []*QuotaConditions `json:"conditions"`
Actions *QuotaAction `json:"action"`

Command string
MatchCmd string
Timer *time.Ticker
ChSignal chan bool
}

// QuotaSettings is the main data structure for Quota Management.
// It contains an array of QuotaConfigurations, an array of QuotaRules and an array
// of exceed_actions.
type QuotaSettings struct {
Enabled bool `json:"enabled"`
Configurations []*QuotaConfiguration `json:"configuration"`
Rules []*QuotaRules `json:"rules"`
ExceedActions []*QuotaExceedActions `json:"exceed_actions"`
}