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

Add order parameter to jobs inspecting API #37

Merged
merged 11 commits into from
Aug 23, 2019

Conversation

Sixeight
Copy link
Contributor

What

  • I introduce new order parameter for jobs inspecting API. We can inspect jobs in arbitrary order by fnext_try field.

Why

  • I want to seek some job, for example, waiting job that will grab next time.
  • /queue/default/waiting?order=asc&limit=1 satisfies the behavior.

}
}

func (i *inspector) findAllAsc(status string, minTime int64, maxTime int64, limit uint, cursor string) (*jobqueue.InspectedJobs, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method has many duplicated code with findAllDesc 🤔 but I cannot split these method as simple.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't surprise me. There is duplicated code already in failureLog.

@Sixeight Sixeight requested a review from tarao August 23, 2019 01:17
@Sixeight Sixeight self-assigned this Aug 23, 2019
Copy link
Member

@tarao tarao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sixeight It looks almost OK. I have some minor change requests.

maxTime = int64(t)
maxJobID = uint64(j)
*time = int64(t)
*jobID = uint64(j)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This mutation looks tricky to me. Consider making this function immutable by taking default values and returning a pair:

func decodeCursor(cursor string, defaultTime int64, defaultJobID uint64) (time int64, jobID uint64)

}
}

func (i *inspector) findAllAsc(status string, minTime int64, maxTime int64, limit uint, cursor string) (*jobqueue.InspectedJobs, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't surprise me. There is duplicated code already in failureLog.

if len(r2.Jobs) != 0 {
t.Error("There must be no waiting job in the queue")
}

r3, err := i.FindAllDeferred(uint(100), "")
r3, err := i.FindAllDeferred(uint(100), "", jobqueue.Desc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to have tests for asceding order too.

@Sixeight
Copy link
Contributor Author

@tarao Thank you for your review. I've corresponded to your point. Could you review again?

@Sixeight Sixeight force-pushed the add-sort-order-to-joblist-api branch from ecb85d9 to 3e86a12 Compare August 23, 2019 07:30
Copy link
Member

@tarao tarao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sixeight LGTM

@Sixeight
Copy link
Contributor Author

Thank you!

@Sixeight Sixeight merged commit 8eee9a8 into master Aug 23, 2019
@Sixeight Sixeight deleted the add-sort-order-to-joblist-api branch August 23, 2019 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants