-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add goroutine to update taskinfo #236
Conversation
go func() { | ||
for { | ||
select { | ||
case <-time.After(100 * time.Millisecond): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to use time.Ticker
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And it's need to update every 100
millisecond ?
} | ||
result.Total = int64(len(result.List)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thank it is not the total
of record in db.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -93,6 +93,21 @@ func Import(taskID string, conf *importconfig.YAMLConfig) (err error) { | |||
} | |||
|
|||
task, _ := GetTaskMgr().GetTask(taskID) | |||
signal := make(chan struct{}, 1) | |||
go func() { | |||
ticker := time.NewTicker(2 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add defer ticker.Stop
?
tx := t.Model(&TaskInfo{}).Where("nebula_address = ? And user = ?", nebulaAddress, user) | ||
tx.Count(&count) | ||
if err := tx.Offset((pageIndex - 1) * pageSize).Limit(pageSize).Find(&tasks).Error; err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you test it?
fix fix fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
solve issue228