ardanlabs / service

Starter-kit for writing services in Go using Kubernetes.
https://www.ardanlabs.com
Apache License 2.0
3.43k stars 619 forks source link

Feature/sql_err_handling #216

Closed jtrinh27 closed 2 years ago

jtrinh27 commented 2 years ago
cip8 commented 2 years ago

Thanks for sharing, I think this is a really useful addition! Unique checks are common in my app and I hacked them by querying the resource first, to see if I have a duplicate 😅😅 Leveraging pq error codes is much more effective & elegant 💡

ardan-bkennedy commented 2 years ago

At quick glance it looks good. I need to look closer and will later today. Thanks.

In the meantime, please add yourself to the CONTRIBUTORS file.

jtrinh27 commented 2 years ago

Thanks for sharing, I think this is a really useful addition! Unique checks are common in my app and I hacked them by querying the resource first, to see if I have a duplicate sweat_smilesweat_smile Leveraging pq error codes is much more effective & elegant bulb

@ciprian-cimpan Thanks! It saves an extra call to the db and alleviates "some" bottlenecks due to network i/o being the most likely cause for drop is application performance; like what @ardan-bkennedy constantly reminds people of.

There is this repo https://github.com/omeid/pgerror/blob/master/pgerror.go that we can perhaps incorporate in this repo or our own private repo to usage. I didn't import it as a vendor because that's a decision is up to someone else to re-engineer. For the project to leverage this, i think Bill should have more situational awareness (SA) and decision making since he uses this repo a lot for his courses.

cip8 commented 2 years ago

There is this repo https://github.com/omeid/pgerror/blob/master/pgerror.go that we can perhaps incorporate in this repo or our own private repo to usage.

Indeed, that's really useful! I bookmarked the repo & might use it in the future, but for my project I will only keep your unique constraint check addition, as that seems to be the most frequently needed.

ardan-bkennedy commented 2 years ago

Please add your name/email to the CONTRINBUTORS file and I will accept the PR.

jtrinh27 commented 2 years ago

Please add your name/email to the CONTRINBUTORS file and I will accept the PR.

Hi Bill,

I am currently in there already (twice): https://github.com/ardanlabs/service/blob/master/CONTRIBUTORS#L43-L44