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

Added read, pause, resume and delete for queue #15

Merged
merged 12 commits into from
Feb 1, 2022

Conversation

sijinpavithran
Copy link
Collaborator

Added queue functions based on Chi router. Kindly review.

Copy link
Contributor

@daltonfury42 daltonfury42 left a comment

Choose a reason for hiding this comment

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

@aneeshsharma pl review, you are the golang/mongo expert here. ✌️

internal/datastore/mongo_store.go Outdated Show resolved Hide resolved
}

func (mongodb MongoDB) PauseQueue(models.QueueId) {
panic("Not implemented")
func (mongodb MongoDB) PauseQueue(id models.QueueId) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The code for this function and resume function is identical.

Let's have one setIsPaused(id models.QueueId, isPaused boolean) private function and then call it with true/false in PauseQueue/ResumeQueue

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added setIsPaused()

Comment on lines 23 to 24
json.NewEncoder(w).Encode(q)
fmt.Fprintf(w, "Get queue")
Copy link
Contributor

@daltonfury42 daltonfury42 Jan 1, 2022

Choose a reason for hiding this comment

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

what does line 24 do? Why do we need both lines 23 and 24?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right. Line 24 is not needed. I will remove it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

internal/mux/mux.go Outdated Show resolved Hide resolved
@daltonfury42 daltonfury42 requested a review from maaverik January 1, 2022 17:45
internal/datastore/mongo_store.go Show resolved Hide resolved
internal/datastore/mongo_store.go Outdated Show resolved Hide resolved
internal/mux/mux.go Outdated Show resolved Hide resolved
@sijinpavithran sijinpavithran marked this pull request as ready for review January 12, 2022 10:48
fmt.Fprintf(w, "GET Queue not implemented")
id := r.Context().Value("id").(string)
if id == "" {
http.Error(w, fmt.Sprintf("Invalid Id: %s", id), 404)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you replace the status code numerical values with constants from the http package:
400 -> hhtp.StatusBadRequest, 404 -> http.StatusNotFound to make it a bit more explicit and less error prone?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hey, did you forget to push your commits? I don't see any changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Apologies. I have pushed now.

Copy link
Contributor

@aneeshsharma aneeshsharma left a comment

Choose a reason for hiding this comment

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

QueueStore should be independent of the database we are using.

internal/datastore/mongo_store.go Outdated Show resolved Hide resolved
internal/datastore/mongo_store.go Outdated Show resolved Hide resolved
internal/datastore/store.go Outdated Show resolved Hide resolved
Copy link
Contributor

@maaverik maaverik left a comment

Choose a reason for hiding this comment

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

Thanks for the PR :)

@maaverik maaverik merged commit a149826 into main Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants