Documentation ¶
Index ¶
- Constants
- func Encrypt(raw string) string
- type AlertMetricsData
- type AuthPermission
- type Feature
- type FeatureMapping
- type I18nTranslation
- type InsertPage
- type LogTableInfo
- type MenuItem
- type Operator
- type OtherLogTable
- type Repo
- type Role
- type Router
- type RouterInsertPage
- type Threshold
- type User
- type UserRole
Constants ¶
View Source
const ERROR_RATE = 5.0
View Source
const GLOBAL = "global"
User-configured threshold table
View Source
const LATENCY = 5.0
View Source
const LOG = 5.0
View Source
const TPS = 5.0
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AlertMetricsData ¶
type AlertMetricsData struct { Id int `json:"-" gorm:"primaryKey;autoIncrement"` Name string `json:"name" gorm:"not null;type:varchar(100);column:name"` PQL string `json:"pql" gorm:"not null;type:varchar(5000);column:pql"` Unit string `json:"unit" gorm:"not null;type:varchar(100);column:unit"` Group string `json:"group" gorm:"not null;type:varchar(100);column:group"` }
AlertMetricsData provide PQL corresponding to user selectable metrics
func (*AlertMetricsData) TableName ¶
func (a *AlertMetricsData) TableName() string
type AuthPermission ¶
type AuthPermission struct { ID int `gorm:"primary_key;auto_increment" json:"id"` Type string `gorm:"column:type;index:idx_sub_id_type" json:"type"` // feature data SubjectID int64 `gorm:"column:subject_id;index:idx_sub_id_type" json:"subjectId"` // Role id, user id or team id. SubjectType string `gorm:"column:subject_type" json:"subjectType"` // role user team. PermissionID int `gorm:"column:permission_id" json:"permissionId"` }
AuthPermission Records which feature are authorised to which subjects.
func (*AuthPermission) TableName ¶
func (t *AuthPermission) TableName() string
type Feature ¶
type Feature struct { FeatureID int `gorm:"column:feature_id;primary_key;auto_increment" json:"featureId"` FeatureName string `gorm:"column:feature_name" json:"featureName"` ParentID *int `gorm:"column:parent_id" json:"-"` Custom bool `gorm:"column:custom;default:false" json:"-"` Children []Feature `gorm:"-" json:"children,omitempty" swaggerignore:"true"` Source string `gorm:"-" json:"source,omitempty"` }
Feature is a collection of APIs, frontend routes and menu items that represents the embodiment of access control.
type FeatureMapping ¶
type FeatureMapping struct { ID int `gorm:"column:id;primary_key"` FeatureID int `gorm:"column:feature_id;index:feature_mapped_idx"` MappedID int `gorm:"column:mapped_id;index:feature_mapped_idx"` MappedType string `gorm:"column:mapped_type"` // menu router api }
FeatureMapping maps feature to menu item, router and api.
func (*FeatureMapping) TableName ¶
func (t *FeatureMapping) TableName() string
type I18nTranslation ¶
type I18nTranslation struct { ID int `gorm:"column:id;primary_key;auto_increment" json:"-"` Language string `gorm:"column:language;index:idx_entity_lang,priority:3" json:"-" mapstructure:"language"` // en, zh, etc. Translation string `gorm:"column:translation" json:"translation" mapstructure:"translation"` FieldName string `gorm:"column:field_name" json:"field_name" mapstructure:"field_name"` // which field is translated EntityID int `gorm:"column:entity_id;index:idx_entity_lang,priority:1" json:"-"` EntityType string `gorm:"column:entity_type;index:idx_entity_lang,priority:2" json:"-" mapstructure:"entity_type"` // menu_item or feature }
func (I18nTranslation) TableName ¶
func (I18nTranslation) TableName() string
type InsertPage ¶
type InsertPage struct { PageID int `gorm:"column:page_id;primary_key;auto_increment" json:"pageId"` Url string `gorm:"column:url" json:"url"` Type string `gorm:"column:type" json:"type"` // For now it's grafana or jaeger. Custom bool `gorm:"column:custom" json:"-"` }
InsertPage saves embedded interface.
func (*InsertPage) TableName ¶
func (t *InsertPage) TableName() string
type LogTableInfo ¶
type LogTableInfo struct { ID uint `gorm:"primaryKey;autoIncrement"` DataBase string `gorm:"type:varchar(100);column:database"` Table string `gorm:"type:varchar(100);column:tablename"` Cluster string `gorm:"type:varchar(100)"` Fields string `gorm:"type:varchar(5000)"` // log field type ParseName string `gorm:"type:varchar(100);column:parsename"` RouteRule string `gorm:"type:varchar(1000);column:routerule"` // routing rule ParseRule string `gorm:"type:varchar(5000);column:parserule"` // parsing rules ParseInfo string `gorm:"type:varchar(100);column:parseinfo"` Service string `gorm:"type:varchar(100)"` IsStructured bool `gorm:"type:bool;column:structured"` }
func (LogTableInfo) TableName ¶
func (LogTableInfo) TableName() string
type MenuItem ¶
type MenuItem struct { ItemID int `gorm:"column:item_id;primary_key" json:"itemId"` Key string `gorm:"column:key;uniqueIndex" json:"key"` Label string `gorm:"-" json:"label"` // AKA item name. Icon string `gorm:"column:icon" json:"icon,omitempty"` ParentID *int `gorm:"column:parent_id" json:"-"` Abbreviation string `gorm:"-" json:"abbreviation,omitempty"` RouterID int `gorm:"column:router_id" json:"-"` Order int `gorm:"column:sort_order;index:sort_order_idx" json:"-"` // The order of a menu item. Children []MenuItem `gorm:"-" json:"children,omitempty" swaggerignore:"true"` Router *Router `gorm:"-" json:"router,omitempty"` // Frontend router. }
MenuItem is a menu item on the left or top menu bar.
type OtherLogTable ¶
type OtherLogTable struct { ID uint `gorm:"primaryKey;autoIncrement"` DataBase string `gorm:"type:varchar(100);column:database"` Table string `gorm:"type:varchar(100);column:tablename"` Cluster string `gorm:"type:varchar(100)"` TimeField string `gorm:"type:varchar(100);column:timefield"` LogField string `gorm:"type:varchar(100);column:logfield"` Instance string `gorm:"type:varchar(100)"` }
func (OtherLogTable) TableName ¶
func (OtherLogTable) TableName() string
type Repo ¶
type Repo interface { CreateOrUpdateThreshold(model *Threshold) error GetOrCreateThreshold(serviceName string, endPoint string, level string) (Threshold, error) DeleteThreshold(serviceName string, endPoint string) error OperateLogTableInfo(model *LogTableInfo, op Operator) error GetAllLogTable() ([]LogTableInfo, error) UpdateLogParseRule(model *LogTableInfo) error GetAllOtherLogTable() ([]OtherLogTable, error) OperatorOtherLogTable(model *OtherLogTable, op Operator) error CreateDingTalkReceiver(dingTalkConfig *amconfig.DingTalkConfig) error // GetDingTalkReceiver get the webhook URL secret corresponding to the uuid. GetDingTalkReceiver(uuid string) (amconfig.DingTalkConfig, error) GetDingTalkReceiverByAlertName(configFile string, alertName string, page, pageSize int) ([]*amconfig.DingTalkConfig, int64, error) UpdateDingTalkReceiver(dingTalkConfig *amconfig.DingTalkConfig, oldName string) error DeleteDingTalkReceiver(configFile, alertName string) error ListQuickAlertRuleMetric() ([]AlertMetricsData, error) Login(username, password string) (*User, error) CreateUser(ctx context.Context, user *User) error UpdateUserPhone(userID int64, phone string) error UpdateUserEmail(userID int64, email string) error UpdateUserPassword(userID int64, oldPassword, newPassword string) error UpdateUserInfo(req *request.UpdateUserInfoRequest) error GetUserInfo(userID int64) (User, error) GetAnonymousUser() (User, error) GetUserList(req *request.GetUserListRequest) ([]User, int64, error) RemoveUser(ctx context.Context, userID int64) error RestPassword(userID int64, newPassword string) error UserExists(userID int64) (bool, error) GetUserRole(userID int64) ([]UserRole, error) GetUsersRole(userIDs []int64) ([]UserRole, error) GetRoles(filter model.RoleFilter) ([]Role, error) GetFeature(featureIDs []int) ([]Feature, error) GetFeatureByName(name string) (int, error) GrantRole(ctx context.Context, userID int64, roleIDs []int) error RevokeRole(ctx context.Context, userID int64, roleIDs []int) error GetSubjectPermission(subID int64, subType string, typ string) ([]int, error) GetSubjectsPermission(subIDs []int64, subType string, typ string) ([]AuthPermission, error) RoleExists(roleID int64) (bool, error) GrantPermission(ctx context.Context, subID int64, subType string, typ string, permissionIDs []int) error RevokePermission(ctx context.Context, subID int64, subType string, typ string, permissionIDs []int) error RoleGranted(userID int64, roleID int) (bool, error) GetItemRouter(items *[]MenuItem) error GetRouterInsertedPage(routers []*Router) error GetFeatureTans(features *[]Feature, language string) error GetMenuItemTans(menuItems *[]MenuItem, language string) error GetFeatureMapping(featureIDs []int, mappedType string) ([]FeatureMapping, error) GetMenuItems() ([]MenuItem, error) // GetContextDB Gets transaction form ctx. GetContextDB(ctx context.Context) *gorm.DB // WithTransaction Puts transaction into ctx. WithTransaction(ctx context.Context, tx *gorm.DB) context.Context // Transaction Starts a transaction and automatically commit and rollback. Transaction(ctx context.Context, funcs ...func(txCtx context.Context) error) error alert.AlertInput }
Define the Database query interface
type Role ¶
type Role struct { RoleID int `gorm:"column:role_id;primary_key" json:"roleId"` RoleName string `gorm:"column:role_name;uniqueIndex" json:"roleName"` }
Role is a collection of feature permission.
type Router ¶
type Router struct { RouterID int `gorm:"column:router_id;primary_key" json:"routerId"` RouterTo string `gorm:"column:router_to;uniqueIndex" json:"to"` Custom bool `gorm:"column:custom;default:false" json:"-"` HideTimeSelector bool `gorm:"column:hide_time_selector" json:"hideTimeSelector"` Page *InsertPage `gorm:"-" json:"page,omitempty"` }
Router front end router.
type RouterInsertPage ¶
type RouterInsertPage struct { ID int `gorm:"column:id"` RouterID int `gorm:"column:router_id;uniqueIndex"` PageID int `gorm:"column:page_id;"` }
RouterInsertPage maps router to inserted page.
func (RouterInsertPage) TableName ¶
func (RouterInsertPage) TableName() string
type Threshold ¶
type Threshold struct { ID uint `gorm:"primaryKey;autoIncrement"` ServiceName string `gorm:"type:varchar(100)"` Level string `gorm:"type:varchar(100)"` EndPoint string `gorm:"type:varchar(100)"` Latency float64 `gorm:"type:decimal(10,2)"` Tps float64 `gorm:"type:decimal(10,2)"` ErrorRate float64 `gorm:"type:decimal(10,2)"` Log float64 `gorm:"type:decimal(10,2)"` }
type User ¶
type User struct { UserID int64 `gorm:"column:user_id;primary_key" json:"userId,omitempty"` Username string `gorm:"column:username;uniqueIdx" json:"username,omitempty"` Password string `gorm:"column:password" json:"-"` Role string `gorm:"column:role" json:"role,omitempty"` Phone string `gorm:"column:phone" json:"phone,omitempty"` Email string `gorm:"column:email" json:"email,omitempty"` Corporation string `gorm:"column:corporation" json:"corporation,omitempty"` RoleList []Role `gorm:"-" json:"roleList,omitempty"` FeatureList []Feature `gorm:"-" json:"featureList,omitempty"` }
Source Files ¶
- alert_manager.go
- dao.go
- dao_feature.go
- dao_i18n.go
- dao_init.go
- dao_insert_page.go
- dao_logtableinfo.go
- dao_menu.go
- dao_othertableinfo.go
- dao_permission.go
- dao_quick_alert_rule_metric.go
- dao_role.go
- dao_router.go
- dao_threshold.go
- dao_user.go
- init_feature.go
- init_feature_mapping.go
- init_i18n.go
- init_insert_page.go
- init_menu_item.go
- init_permission.go
- init_role.go
- init_router.go
- init_router_page.go
- transaction.go
Click to show internal directories.
Click to hide internal directories.