Rainbond/db/model/event.go

128 lines
4.0 KiB
Go
Raw Normal View History

2018-03-14 14:12:26 +08:00
// Copyright (C) 2014-2018 Goodrain Co., Ltd.
// RAINBOND, Application Management Platform
2018-03-14 14:33:31 +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
// 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
// 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
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"
//ServiceEvent event struct
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"`
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"`
}
//TableName 表名
func (t *ServiceEvent) TableName() string {
return "tenant_services_event"
}
//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"`
Hash string `gorm:"column:hash;size:100"`
//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"`
}
//TableName table name
func (n *NotificationEvent) TableName() string {
return "region_notification_event"
}