mirror of
https://github.com/ccfos/nightingale.git
synced 2026-03-04 15:08:52 +00:00
Compare commits
3 Commits
dev23
...
release-22
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
36569af554 | ||
|
|
2b89ccf43c | ||
|
|
6a9ecee1bc |
@@ -191,6 +191,7 @@ func HandleHeartbeat(c *gin.Context, ctx *ctx.Context, engineName string, metaSe
|
||||
}
|
||||
|
||||
if targetNeedUpdate {
|
||||
newTarget.UpdateAt = time.Now().Unix()
|
||||
err := models.DB(ctx).Model(&target).Updates(newTarget).Error
|
||||
if err != nil {
|
||||
logger.Errorf("update target fields failed, err: %v", err)
|
||||
|
||||
@@ -201,7 +201,7 @@ func (d *Doris) NewWriteConn(ctx context.Context, database string) (*sql.DB, err
|
||||
func (d *Doris) createTimeoutContext(ctx context.Context) (context.Context, context.CancelFunc) {
|
||||
timeout := d.Timeout
|
||||
if timeout == 0 {
|
||||
timeout = 60
|
||||
timeout = 60000
|
||||
}
|
||||
return context.WithTimeout(ctx, time.Duration(timeout)*time.Millisecond)
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ func TargetBindBgids(ctx *ctx.Context, idents []string, bgids []int64, tags []st
|
||||
}
|
||||
|
||||
return DB(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
if err := DB(ctx).Clauses(cl).CreateInBatches(&lst, 10).Error; err != nil {
|
||||
if err := tx.Clauses(cl).CreateInBatches(&lst, 10).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
if targets, err := TargetsGetByIdents(ctx, idents); err != nil {
|
||||
@@ -100,13 +100,24 @@ func TargetBindBgids(ctx *ctx.Context, idents []string, bgids []int64, tags []st
|
||||
}
|
||||
}
|
||||
|
||||
// update target.update_at so that syncTargets can detect the change and refresh GroupIds cache
|
||||
if err := tx.Model(&Target{}).Where("ident in ?", idents).Update("update_at", updateAt).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func TargetUnbindBgids(ctx *ctx.Context, idents []string, bgids []int64) error {
|
||||
return DB(ctx).Where("target_ident in ? and group_id in ?",
|
||||
idents, bgids).Delete(&TargetBusiGroup{}).Error
|
||||
return DB(ctx).Transaction(func(tx *gorm.DB) error {
|
||||
if err := tx.Where("target_ident in ? and group_id in ?",
|
||||
idents, bgids).Delete(&TargetBusiGroup{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
// update target.update_at so that syncTargets can detect the change and refresh GroupIds cache
|
||||
return tx.Model(&Target{}).Where("ident in ?", idents).Update("update_at", time.Now().Unix()).Error
|
||||
})
|
||||
}
|
||||
|
||||
func TargetDeleteBgids(tx *gorm.DB, idents []string) error {
|
||||
@@ -150,7 +161,8 @@ func TargetOverrideBgids(ctx *ctx.Context, idents []string, bgids []int64, tags
|
||||
return err
|
||||
}
|
||||
if len(tags) == 0 {
|
||||
return nil
|
||||
// update target.update_at so that syncTargets can detect the change and refresh GroupIds cache
|
||||
return tx.Model(&Target{}).Where("ident IN ?", idents).Update("update_at", updateAt).Error
|
||||
}
|
||||
|
||||
return tx.Model(Target{}).Where("ident IN ?", idents).Updates(map[string]interface{}{
|
||||
|
||||
Reference in New Issue
Block a user