-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: add db package #38
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.
Since this is a pretty important part of an application (interacting with the main source) and we will use it across our odpf services, should we consider adding test? at least for migration and transaction.
wdyt?
db/config.go
Outdated
) | ||
|
||
type Config struct { | ||
Driver string `yaml:"driver" mapstructure:"driver"` |
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.
do we need these yaml
& mapstructure
tags here?
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.
So that when we compose this in a higher level config struct, we can tell viper what names to use in the configs passed through yaml file. Any other suggestion to achieve that?
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.
I think this the best way to do it.
P.S.: I think, these kinds of tags are okay (even good) to be there for any struct even if you don't have immediate need -- They don't really have an inherent cost and when you actually need to use the struct to show/read yaml/json etc. it just works. (It just says "if you were to represent this in YAML, these are the key names you should be 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.
+1
@StewartJingga @krtkvrm Added high-level tests for both. Please check. Let me know if we need to make them more strict. |
Common package for connecting to SQL databases