Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,40 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"alarm.go",
"app.go",
"apply.go",
"auth.go",
"filter.go",
"message.go",
"notify.go",
"notifygroup.go",
"oldapp.go",
"oldauth.go",
"topic.go",
],
importpath = "go-common/app/admin/main/apm/model/databus",
tags = ["automanaged"],
deps = ["//library/time:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,96 @@
package databus
// AlarmOpen ...
type AlarmOpen struct {
ReqID string `json:"ReqId"`
Action string `json:"Action"`
RetCode int64 `json:"RetCode"`
Data []*Open `json:"Data"`
}
// Open ...
type Open struct {
AdjustID string `json:"adjust_id"`
PolicyID string `json:"policy_id"`
Group string `json:"group"`
}
//Scope ...
type Scope struct {
Type int64
Key string
Val []string
}
//Owner ...
type Owner struct {
Owner string `json:"owner"`
App string `json:"app"`
}
// Res ...
type Res struct {
ReqID string `json:"ReqId"`
Action string `json:"Action"`
RetCode int64 `json:"RetCode"`
Data Opsmind `json:"Data"`
}
// Opsmind ...
type Opsmind struct {
PolicyID string `json:"policy_id"`
AdjustID string `json:"adjust_id"`
Category string `json:"category"`
Scope string `json:"scope"`
TriggerID string `json:"trigger_id"`
TriggerLevel string `json:"trigger_level"`
TriggerFor int64 `json:"trigger_for"`
TriggerNotes string `json:"trigger_notes"`
TriggerOperator string `json:"trigger_operator"`
TriggerThreshold int64 `json:"trigger_threshold"`
Silence bool `json:"silence"`
Hashid string `json:"hashid"`
ExpiredAt string `json:"expired_at"`
}
//Query ...
type Query struct {
Key string
Val []string
}
// ResQuery ...
type ResQuery struct {
ReqID string `json:"ReqId"`
Action string `json:"Action"`
RetCode int64 `json:"RetCode"`
Data []*Querys `json:"Data"`
}
// Querys ...
type Querys struct {
ID string `json:"id"`
PolicyID string `json:"policy_id"`
Creator string `json:"creator"`
Ctime int64 `json:"ctime"`
Mtime int64 `json:"mtime"`
Scope []*Scope `json:"scope"`
Triggers []*Trigger `json:"triggers"`
Notes *Owner `json:"notes"`
Desc string `json:"desc"`
Silence bool `json:"silence"`
ExpiredAt int64 `json:"expired_at"`
}
//Trigger ...
type Trigger struct {
ID string `json:"id"`
Desc string `json:"desc"`
Operator string `json:"operator"`
For int64 `json:"for"`
Threshold float64 `json:"threshold"`
Level string `json:"level"`
NodataType string `json:"nodata_type"`
NodataFor int64 `json:"nodata_for"`
Notes *Owner `json:"notes"`
}

View File

@@ -0,0 +1,19 @@
package databus
import "go-common/library/time"
// TableName case tablename
func (*App) TableName() string {
return "app2"
}
// App app model
type App struct {
ID int `gorm:"column:id" json:"id"`
AppKey string `gorm:"column:app_key" json:"app_key"`
AppSecret string `gorm:"column:app_secret" json:"app_secret"`
Project string `gorm:"column:project" json:"cluster"`
Remark string `gorm:"column:remark" json:"remark"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"-"`
}

View File

@@ -0,0 +1,37 @@
package databus
import "go-common/library/time"
// TableName case tablename
func (*Apply) TableName() string {
return "group_apply"
}
// Apply apply model
type Apply struct {
ID int `gorm:"column:id" json:"id"`
Group string `gorm:"column:group" json:"group"`
Cluster string `gorm:"column:cluster" json:"cluster"`
TopicRemark string `gorm:"column:topic_remark" json:"topic_remark"`
TopicID int `gorm:"column:topic_id" json:"topic_id"`
TopicName string `gorm:"column:topic_name" json:"topic"`
AppID int `gorm:"column:app_id" json:"app_id"`
Project string `gorm:"column:project" json:"project"`
Operation int8 `gorm:"column:operation" json:"operation"`
State int8 `gorm:"column:state" json:"state"`
Operator string `gorm:"column:operator" json:"operator"`
Remark string `gorm:"column:remark" json:"remark"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
// notify
Gid int `gorm:"-" json:"notify_gid"`
Nid int64 `gorm:"-" json:"notify_id"`
Offset string `gorm:"-" json:"notify_offset"`
Nstate int8 `gorm:"-" json:"notify_state"`
Filter int8 `gorm:"-" json:"notify_filter"`
Concurrent int8 `gorm:"-" json:"notify_concurrent"`
Callback string `gorm:"-" json:"notify_callback"`
Filters string `gorm:"-" json:"-"`
FilterList []*Filter `gorm:"-" json:"filters"`
Zone string `gorm:"-" json:"notify_zone"`
}

View File

@@ -0,0 +1,65 @@
package databus
import (
"go-common/library/time"
)
// TableName case tablename
func (*Group) TableName() string {
return "auth2"
}
// Group group model
type Group struct {
ID int `gorm:"column:id" json:"id"`
Group string `gorm:"column:group" json:"group"`
AppID int `gorm:"column:app_id" json:"app_id"`
AppKey string `gorm:"-" json:"app_key"`
Project string `gorm:"-" json:"project"`
TopicID int `gorm:"column:topic_id" json:"topic_id"`
Topic string `gorm:"-" json:"topic"`
Cluster string `gorm:"-" json:"cluster"`
Operation int8 `gorm:"column:operation" json:"operation"`
IsDelete int8 `gorm:"column:is_delete" json:"is_delete"`
Remark string `gorm:"column:remark" json:"remark"`
Alarm int8 `gorm:"column:alarm;default:1" json:"alarm"`
Percentage string `gorm:"column:percentage" json:"percentage"`
Number int `gorm:"column:number" json:"number"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
Callback string `gorm:"-" json:"notify_callback"`
Concurrent string `gorm:"-" json:"notify_concurrent"`
Filter int8 `gorm:"-" json:"notify_filter"`
Filters string `gorm:"-" json:"-"`
FilterList []*Filter `gorm:"-" json:"filters"`
State int8 `gorm:"-" json:"notify_state"`
Gid int64 `gorm:"-" json:"notify_gid"`
Nid int64 `gorm:"-" json:"notify_id"`
Zone string `gorm:"-" json:"notify_zone"`
}
//Alarm alarm
type Alarm struct {
Group string `json:"group"`
Project string `json:"project"`
Alarm int8 `json:"alarm"`
Percentage string `json:"percentage"`
}
//Alarms alarms
type Alarms struct {
Cluster string `json:"cluster"`
Topic string `json:"topic"`
Group string `json:"group"`
Project string `json:"project"`
Alarm int8 `json:"alarm"`
Percentage string `json:"percentage"`
Diff []*Record `json:"diff"`
}
// Record diff
type Record struct {
Partition int32 `json:"partition"`
Diff int64 `json:"diff"`
New int64 `json:"new"`
}

View File

@@ -0,0 +1,16 @@
package databus
// TableName case tablename
func (*Filter) TableName() string {
return "filters"
}
// Filter apply model
type Filter struct {
ID int `gorm:"column:id" json:"id"`
Nid int `gorm:"column:nid" json:"nid"`
Filters string `gorm:"column:filters" json:"-"`
Field string `gorm:"-" json:"field"`
Condition int8 `gorm:"-" json:"condition"`
Value string `gorm:"-" json:"value"`
}

View File

@@ -0,0 +1,11 @@
package databus
// Message Data.
type Message struct {
Key string `json:"key"`
Value string `json:"value"`
Topic string `json:"topic"`
Partition int32 `json:"partition"`
Offset int64 `json:"offset"`
Timestamp int64 `json:"timestamp"`
}

View File

@@ -0,0 +1,22 @@
package databus
import "go-common/library/time"
// TableName case tablename
func (*Notify) TableName() string {
return "notify"
}
// Notify apply model
type Notify struct {
ID int `gorm:"column:id" json:"id"`
Gid int `gorm:"column:gid" json:"gid"`
Offset string `gorm:"column:offset" json:"offset"`
State int8 `gorm:"column:state" json:"state"`
Filter int8 `gorm:"column:filter" json:"filter"`
Concurrent int8 `gorm:"column:concurrent" json:"concurrent"`
Callback string `gorm:"column:callback" json:"callback"`
Zone string `gorm:"column:zone" json:"zone"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
}

View File

@@ -0,0 +1,34 @@
package databus
import "go-common/library/time"
// TableName case tablename
func (*NotifyGroup) TableName() string {
return "group_apply"
}
// NotifyGroup apply model
type NotifyGroup struct {
ID int `gorm:"column:id" json:"notify_id"`
Gid int `gorm:"column:gid" json:"notify_gid"`
Offset string `gorm:"column:offset" json:"notify_offset"`
State int8 `gorm:"column:state" json:"notify_state"`
Filter int8 `gorm:"column:filter" json:"notify_filter"`
Concurrent int8 `gorm:"column:concurrent" json:"notify_concurrent"`
Callback string `gorm:"column:callback" json:"notify_callback"`
Ctime time.Time `gorm:"column:ctime" json:"notify_ctime"`
Mtime time.Time `gorm:"column:mtime" json:"notify_mtime"`
GGroup string `gorm:"column:group" json:"group"`
GCluster string `gorm:"column:cluster" json:"cluster"`
GTopicRemark string `gorm:"column:topic_remark" json:"topic_remark"`
GTopicID int `gorm:"column:topic_id" json:"topic_id"`
GTopicName string `gorm:"column:topic_name" json:"topic"`
GAppID int `gorm:"column:app_id" json:"app_id"`
GState int8 `gorm:"column:gstate" json:"state"`
GOperation int8 `gorm:"column:operation" json:"operation"`
GOperator string `gorm:"column:operator" json:"operator"`
GRemark string `gorm:"column:remark" json:"remark"`
Filters string `gorm:"column:filters" json:"filters"`
GCtime time.Time `gorm:"column:gctime" json:"ctime"`
GMtime time.Time `gorm:"column:gmtime" json:"mtime"`
}

View File

@@ -0,0 +1,18 @@
package databus
import "go-common/library/time"
// TableName case tablename
func (*OldApp) TableName() string {
return "app"
}
// OldApp app model
type OldApp struct {
ID int64 `gorm:"column:id" json:"id"`
AppKey string `gorm:"column:app_key" json:"app_key"`
AppSecret string `gorm:"column:app_secret" json:"app_secret"`
Cluster string `gorm:"column:cluster" json:"cluster"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"-"`
}

View File

@@ -0,0 +1,22 @@
package databus
import (
"go-common/library/time"
)
// TableName case tablename
func (*OldAuth) TableName() string {
return "auth"
}
// OldAuth group model
type OldAuth struct {
ID int64 `gorm:"column:id" json:"id"`
GroupName string `gorm:"column:group_name" json:"group_name"`
Topic string `gorm:"column:topic" json:"topic"`
Business string `gorm:"business" json:"business"`
AppID int64 `gorm:"column:app_id" json:"app_id"`
Operation int8 `gorm:"column:operation" json:"operation"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"mtime"`
}

View File

@@ -0,0 +1,20 @@
package databus
import (
"go-common/library/time"
)
// TableName case tablename
func (*Topic) TableName() string {
return "topic"
}
// Topic topic
type Topic struct {
ID int `gorm:"column:id" json:"id"`
Topic string `gorm:"column:topic" json:"topic"`
Cluster string `gorm:"column:cluster" json:"cluster"`
Remark string `gorm:"column:remark" json:"remark"`
Ctime time.Time `gorm:"column:ctime" json:"ctime"`
Mtime time.Time `gorm:"column:mtime" json:"-"`
}