mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Fix runtime updates
This commit is contained in:
parent
c8c50cea82
commit
9eff41359a
51 changed files with 57 additions and 57 deletions
|
|
@ -100,7 +100,7 @@ func Operator(super *supervisor.Supervisor, chHA chan int, objectInformation *co
|
|||
go UpdatePrepWorker(super, objectInformation, done, chUpdate, chUpdateBack)
|
||||
go UpdateExecWorker(super, objectInformation, done, chUpdateBack, wgUpdate, updateCounter)
|
||||
|
||||
go RuntimeUpdateWorker(super, objectInformation, done, chInsert, chDelete, wgInsert, wgDelete)
|
||||
go RuntimeUpdateWorker(super, objectInformation, done, chUpdate, chDelete, wgUpdate, wgDelete)
|
||||
|
||||
waitOrKill := func(wg *sync.WaitGroup, done chan struct{}) (kill bool) {
|
||||
waitDone := make(chan bool)
|
||||
|
|
@ -426,7 +426,7 @@ func UpdateExecWorker(super *supervisor.Supervisor, objectInformation *configobj
|
|||
}
|
||||
}
|
||||
|
||||
func RuntimeUpdateWorker(super *supervisor.Supervisor, objectInformation *configobject.ObjectInformation, done chan struct{}, chInsert chan []string, chDelete chan []string, wgInsert *sync.WaitGroup, wgDelete *sync.WaitGroup) {
|
||||
func RuntimeUpdateWorker(super *supervisor.Supervisor, objectInformation *configobject.ObjectInformation, done chan struct{}, chUpdate chan []string, chDelete chan []string, wgUpdate *sync.WaitGroup, wgDelete *sync.WaitGroup) {
|
||||
subscription := super.Rdbw.Subscribe()
|
||||
defer subscription.Close()
|
||||
if err := subscription.Subscribe("icinga:config:delete", "icinga:config:update"); err != nil {
|
||||
|
|
@ -459,19 +459,19 @@ func RuntimeUpdateWorker(super *supervisor.Supervisor, objectInformation *config
|
|||
objectId := data[2]
|
||||
switch msg.Channel {
|
||||
case "icinga:config:update":
|
||||
wgInsert.Add(1)
|
||||
chInsert <- []string{objectId}
|
||||
wgUpdate.Add(1)
|
||||
chUpdate <- []string{objectId}
|
||||
log.WithFields(log.Fields{
|
||||
"type": objectInformation.ObjectType,
|
||||
"action": "runtime insert/update",
|
||||
}).Infof("Inserting 1 %v on runtime update", objectInformation.ObjectType)
|
||||
}).Infof("Inserting 1 %v on runtime update (%s)", objectInformation.ObjectType, objectId)
|
||||
case "icinga:config:delete":
|
||||
wgDelete.Add(1)
|
||||
chDelete <- []string{objectId}
|
||||
log.WithFields(log.Fields{
|
||||
"type": objectInformation.ObjectType,
|
||||
"action": "runtime delete",
|
||||
}).Infof("Deleting 1 %v on runtime update", objectInformation.ObjectType)
|
||||
}).Infof("Deleting 1 %v on runtime update (%s)", objectInformation.ObjectType, objectId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewActionUrl,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewCheckCommand,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "checkcommand",
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewCheckCommandArgument,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "checkcommand",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewCheckCommandCustomvar,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "checkcommand",
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewCheckCommandEnvvar,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "checkcommand",
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewCustomvar,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ func init() {
|
|||
PrimaryMySqlField: "customvar_id",
|
||||
Factory: NewCustomvarFlat,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "customvar_id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewEndpoint,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "endpoint",
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewEventCommand,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "eventcommand",
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewEventCommandArgument,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "eventcommand",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewEventCommandCustomvar,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "eventcommand",
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewEventCommandEnvvar,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "eventcommand",
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewHost,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "host",
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewHostComment,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "hostcomment",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewHostCustomvar,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "host",
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewHostDowntime,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "hostdowntime",
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ func init() {
|
|||
PrimaryMySqlField: "host_id",
|
||||
Factory: NewHostState,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "host_id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "host_id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "host",
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewHostgroup,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "hostgroup",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewHostgroupCustomvar,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "hostgroup",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewHostgroupMember,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "host",
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewIconImage,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewNotesUrl,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewNotification,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "notification",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewNotificationCustomvar,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "notification",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewNotificationUser,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "notification",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewNotificationUsergroup,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "notification",
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewNotificationCommand,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "notificationcommand",
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewNotificationCommandArgument,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "notificationcommand",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewNotificationCommandCustomvar,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "notificationcommand",
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewNotificationCommandEnvvar,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "notificationcommand",
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewService,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "service",
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewServiceComment,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "servicecomment",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewServiceCustomvar,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "service",
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewServiceDowntime,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "servicedowntime",
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ func init() {
|
|||
PrimaryMySqlField: "service_id",
|
||||
Factory: NewServiceState,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "service_id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "service_id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "service",
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewServicegroup,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "servicegroup",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewServicegroupCustomvar,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "servicegroup",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewServicegroupMember,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "service",
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewTimeperiod,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "timeperiod",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewTimeperiodCustomvar,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "timeperiod",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewTimeperiodOverrideExclude,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "timeperiod",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewTimeperiodOverrideInclude,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "timeperiod",
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewTimeperiodRange,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "timeperiod",
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewUser,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "user",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewUserCustomvar,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "user",
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewUsergroup,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "usergroup",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewUsergroupCustomvar,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "usergroup",
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewUsergroupMember,
|
||||
HasChecksum: false,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "user",
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ func init() {
|
|||
PrimaryMySqlField: "id",
|
||||
Factory: NewZone,
|
||||
HasChecksum: true,
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields, "id"),
|
||||
BulkInsertStmt: connection.NewBulkInsertStmt(name, Fields),
|
||||
BulkDeleteStmt: connection.NewBulkDeleteStmt(name, "id"),
|
||||
BulkUpdateStmt: connection.NewBulkUpdateStmt(name, Fields),
|
||||
NotificationListenerType: "zone",
|
||||
|
|
|
|||
|
|
@ -376,11 +376,11 @@ type BulkInsertStmt struct {
|
|||
NumField int
|
||||
}
|
||||
|
||||
func NewBulkInsertStmt(table string, fields []string, primaryKey string) *BulkInsertStmt {
|
||||
func NewBulkInsertStmt(table string, fields []string) *BulkInsertStmt {
|
||||
numField := len(fields)
|
||||
placeholder := fmt.Sprintf("(%s)", strings.TrimSuffix(strings.Repeat("?, ", numField), ", "))
|
||||
stmt := BulkInsertStmt{
|
||||
Format: fmt.Sprintf("INSERT INTO %s (%s) VALUES %s ON DUPLICATE KEY UPDATE %s = %s", table, strings.Join(fields, ", "), "%s", primaryKey, primaryKey),
|
||||
Format: fmt.Sprintf("REPLACE INTO %s (%s) VALUES %s", table, strings.Join(fields, ", "), "%s"),
|
||||
Fields: fields,
|
||||
Placeholder: placeholder,
|
||||
NumField: numField,
|
||||
|
|
|
|||
Loading…
Reference in a new issue