2018-03-14 14:12:26 +08:00
|
|
|
// Copyright (C) 2014-2018 Goodrain Co., Ltd.
|
2017-11-16 16:30:22 +08:00
|
|
|
// RAINBOND, Application Management Platform
|
2018-03-14 14:33:31 +08:00
|
|
|
|
2017-11-16 16:30:22 +08:00
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version. For any non-GPL usage of Rainbond,
|
|
|
|
// one or multiple Commercial Licenses authorized by Goodrain Co., Ltd.
|
|
|
|
// must be obtained first.
|
2018-03-14 14:33:31 +08:00
|
|
|
|
2017-11-16 16:30:22 +08:00
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
2018-03-14 14:33:31 +08:00
|
|
|
|
2017-11-16 16:30:22 +08:00
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
package model
|
|
|
|
|
2018-05-11 13:44:15 +08:00
|
|
|
import "time"
|
|
|
|
|
2019-08-24 19:02:24 +08:00
|
|
|
// ASYNEVENTTYPE asyn event type
|
|
|
|
const ASYNEVENTTYPE = 0
|
|
|
|
|
|
|
|
// SYNEVENTTYPE syn event type
|
|
|
|
const SYNEVENTTYPE = 1
|
|
|
|
|
|
|
|
// TargetTypeService service target
|
|
|
|
const TargetTypeService = "service"
|
|
|
|
|
2019-08-29 14:15:46 +08:00
|
|
|
// TargetTypePod -
|
|
|
|
const TargetTypePod = "pod"
|
|
|
|
|
2019-08-24 19:02:24 +08:00
|
|
|
// TargetTypeTenant tenant target
|
|
|
|
const TargetTypeTenant = "tenant"
|
|
|
|
|
2019-08-25 22:19:27 +08:00
|
|
|
// UsernameSystem -
|
|
|
|
const UsernameSystem = "system"
|
|
|
|
|
|
|
|
// EventFinalStatus -
|
|
|
|
type EventFinalStatus string
|
|
|
|
|
|
|
|
// String -
|
|
|
|
func (e EventFinalStatus) String() string {
|
|
|
|
return string(e)
|
|
|
|
}
|
|
|
|
|
|
|
|
// EventFinalStatusComplete -
|
|
|
|
var EventFinalStatusComplete EventFinalStatus = "complete"
|
|
|
|
|
|
|
|
// EventFinalStatusFailure -
|
|
|
|
var EventFinalStatusFailure EventFinalStatus = "failure"
|
|
|
|
|
|
|
|
// EventFinalStatusRunning -
|
|
|
|
var EventFinalStatusRunning EventFinalStatus = "running"
|
|
|
|
|
2019-08-29 14:15:46 +08:00
|
|
|
// EventFinalStatusEmpty -
|
|
|
|
var EventFinalStatusEmpty EventFinalStatus = "empty"
|
|
|
|
|
2019-09-01 11:00:07 +08:00
|
|
|
// EventFinalStatusEmptyComplete -
|
|
|
|
var EventFinalStatusEmptyComplete EventFinalStatus = "emptycomplete"
|
|
|
|
|
|
|
|
// EventStatus -
|
2019-08-29 14:15:46 +08:00
|
|
|
type EventStatus string
|
|
|
|
|
|
|
|
// String -
|
|
|
|
func (e EventStatus) String() string {
|
|
|
|
return string(e)
|
|
|
|
}
|
|
|
|
|
|
|
|
// EventStatusSuccess -
|
|
|
|
var EventStatusSuccess EventStatus = "success"
|
|
|
|
|
2020-06-17 12:57:41 +08:00
|
|
|
// EventStatusFailure -
|
2019-08-29 14:15:46 +08:00
|
|
|
var EventStatusFailure EventStatus = "failure"
|
|
|
|
|
2018-03-29 18:41:08 +08:00
|
|
|
//ServiceEvent event struct
|
2017-11-16 16:30:22 +08:00
|
|
|
type ServiceEvent struct {
|
|
|
|
Model
|
2019-03-08 19:22:22 +08:00
|
|
|
EventID string `gorm:"column:event_id;size:40"`
|
2020-06-17 12:57:41 +08:00
|
|
|
TenantID string `gorm:"column:tenant_id;size:40;index:tenant_id"`
|
|
|
|
ServiceID string `gorm:"column:service_id;size:40;index:service_id"`
|
2019-08-22 16:07:26 +08:00
|
|
|
Target string `gorm:"column:target;size:40"`
|
2021-02-06 13:24:21 +08:00
|
|
|
TargetID string `gorm:"column:target_id;size:255;index:target_id"`
|
2019-09-10 12:59:03 +08:00
|
|
|
RequestBody string `gorm:"column:request_body;size:1024"`
|
2019-03-08 19:22:22 +08:00
|
|
|
UserName string `gorm:"column:user_name;size:40"`
|
|
|
|
StartTime string `gorm:"column:start_time;size:40"`
|
2019-08-22 19:51:46 +08:00
|
|
|
EndTime string `gorm:"column:end_time;size:40"`
|
2019-03-08 19:22:22 +08:00
|
|
|
OptType string `gorm:"column:opt_type;size:40"`
|
2019-08-22 16:07:26 +08:00
|
|
|
SynType int `gorm:"column:syn_type;size:1"`
|
2019-03-08 19:22:22 +08:00
|
|
|
Status string `gorm:"column:status;size:40"`
|
|
|
|
FinalStatus string `gorm:"column:final_status;size:40"`
|
|
|
|
Message string `gorm:"column:message"`
|
2021-05-31 10:55:05 +08:00
|
|
|
Reason string `gorm:"column:reason"`
|
2017-11-16 16:30:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//TableName 表名
|
|
|
|
func (t *ServiceEvent) TableName() string {
|
2018-11-22 14:33:29 +08:00
|
|
|
return "tenant_services_event"
|
2017-11-16 16:30:22 +08:00
|
|
|
}
|
2018-05-11 13:44:15 +08:00
|
|
|
|
|
|
|
//NotificationEvent NotificationEvent
|
|
|
|
type NotificationEvent struct {
|
|
|
|
Model
|
|
|
|
//Kind could be service, tenant, cluster, node
|
|
|
|
Kind string `gorm:"column:kind;size:40"`
|
|
|
|
//KindID could be service_id,tenant_id,cluster_id,node_id
|
|
|
|
KindID string `gorm:"column:kind_id;size:40"`
|
2018-08-08 12:01:04 +08:00
|
|
|
Hash string `gorm:"column:hash;size:100"`
|
2018-05-11 13:44:15 +08:00
|
|
|
//Type could be Normal UnNormal Notification
|
|
|
|
Type string `gorm:"column:type;size:40"`
|
|
|
|
Message string `gorm:"column:message;size:200"`
|
|
|
|
Reason string `gorm:"column:reson;size:200"`
|
|
|
|
Count int `gorm:"column:count;"`
|
|
|
|
LastTime time.Time `gorm:"column:last_time;"`
|
|
|
|
FirstTime time.Time `gorm:"column:first_time;"`
|
|
|
|
IsHandle bool `gorm:"column:is_handle;"`
|
|
|
|
HandleMessage string `gorm:"column:handle_message;"`
|
2018-08-10 10:38:00 +08:00
|
|
|
ServiceName string `gorm:"column:service_name;size:40"`
|
|
|
|
TenantName string `gorm:"column:tenant_name;size:40"`
|
2018-05-11 13:44:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//TableName table name
|
|
|
|
func (n *NotificationEvent) TableName() string {
|
2018-11-22 14:33:29 +08:00
|
|
|
return "region_notification_event"
|
2018-05-11 13:44:15 +08:00
|
|
|
}
|