-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
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.
@aneeshsharma pl review, you are the golang/mongo expert here. ✌️
internal/datastore/mongo_store.go
Outdated
} | ||
|
||
func (mongodb MongoDB) PauseQueue(models.QueueId) { | ||
panic("Not implemented") | ||
func (mongodb MongoDB) PauseQueue(id models.QueueId) { |
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.
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
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.
Added setIsPaused()
internal/handler/queue.go
Outdated
json.NewEncoder(w).Encode(q) | ||
fmt.Fprintf(w, "Get queue") |
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.
what does line 24 do? Why do we need both lines 23 and 24?
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.
You are right. Line 24 is not needed. I will remove it.
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.
Done.
…plQ/simplQ-golang into sijin-q-funcs-implementation
internal/handler/queue.go
Outdated
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) |
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.
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?
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.
Done.
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.
Hey, did you forget to push your commits? I don't see any changes.
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.
Apologies. I have pushed now.
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.
QueueStore
should be independent of the database we are using.
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.
Thanks for the PR :)
Added queue functions based on Chi router. Kindly review.