Fix runtime updates

This commit is contained in:
Noah Hilverling 2019-10-10 10:12:20 +02:00
parent c8c50cea82
commit 9eff41359a
51 changed files with 57 additions and 57 deletions

View file

@ -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)
}
}
}

View file

@ -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),
}

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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),
}

View file

@ -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),
}

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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),
}

View file

@ -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),
}

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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",

View file

@ -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,