Challenge Commit#38
Conversation
alesr
left a comment
There was a problem hiding this comment.
Hey! I'm having a look at your solution. Really clean implementation. I appreciate attention to the details. Nice work! 👍
| } | ||
|
|
||
| // Ensure asset exists. | ||
| if _, err := favService.assetRepo.Get(ctx, assetID); err != nil { |
There was a problem hiding this comment.
Are we actually ensuring that the asset exists before creating the favorite?
In what circumstances could this check fail?
There was a problem hiding this comment.
It ensures the asset exists at the moment assetRepo.Get runs. There’s a time window before favRepo.Create runs, if the asset is deleted in that gap, a race condition can occur. So Get might see the asset, but by the time favRepo.Create writes, it may already be gone.
| go func() { | ||
| log.Info("http server listening", "addr", cfg.HTTPAddr) | ||
| if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) { | ||
| log.Error("http server error", "err", err) |
There was a problem hiding this comment.
What happens if the server stops running?
There was a problem hiding this comment.
If the server stops running, meaning the go funct exits without the gracefull shutdown been trigger, then the error retured from ListenAndServe() would be logged but the main would not know about the server been shut down. This would lead to the app been seemingly running (DB for example been up) but it would not be able to accept any requests.
|
@SokratisChm Thanks for submitting the challenge, we appreciate your effort. You did a great job, with excellent architecture and design patterns, production-ready features such as HTTP server graceful shutdown, Docker Setup, structured logging, etc. Moreover, your RESTful API design and DB schema look great 💯 I would appreciate it if you could take some time to answer the following questions:
|
|
@alesr Thanks so much! Appreciate the review and the kind words |
|
@lkslts64 First of all i would like to thank you for your thoughtfull review of my project! I'm extreamly glad to hear your kind words! Regarding the questions:
|
My implementation of the platform-go-challenge