Skip to content
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

refactor: refactor metric handling by removing IncCompletedTask method #140

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type Metric interface {
IncSuccessTask()
IncFailureTask()
IncSubmittedTask()
IncCompletedTask()
}

var _ Metric = (*metric)(nil)
Expand All @@ -24,7 +23,6 @@ type metric struct {
successTasks uint64
failureTasks uint64
submittedTasks uint64
completedTasks uint64
}

// NewMetric for default metric structure
Expand Down Expand Up @@ -56,10 +54,6 @@ func (m *metric) IncSubmittedTask() {
atomic.AddUint64(&m.submittedTasks, 1)
}

func (m *metric) IncCompletedTask() {
atomic.AddUint64(&m.completedTasks, 1)
}

func (m *metric) SuccessTasks() uint64 {
return atomic.LoadUint64(&m.successTasks)
}
Expand All @@ -73,5 +67,5 @@ func (m *metric) SubmittedTasks() uint64 {
}

func (m *metric) CompletedTasks() uint64 {
return atomic.LoadUint64(&m.completedTasks)
return atomic.LoadUint64(&m.successTasks) + atomic.LoadUint64(&m.failureTasks)
}
1 change: 0 additions & 1 deletion queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ func (q *Queue) work(task core.TaskMessage) {
if q.afterFn != nil {
q.afterFn()
}
q.metric.IncCompletedTask()
}()

if err = q.run(task); err != nil {
Expand Down
Loading