-
Notifications
You must be signed in to change notification settings - Fork 0
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
redis: Configurable Database #50
Conversation
A Redis server might support multiple databases, allowing to use the same Redis for different applications. The database can either be configured for the configuration or later changed via SELECT[0]. By default, the database 0 will be used. While both the used go-redis library and even Icinga 2[1] support this feature, we should expose this here and make this configurable. As discussed in Icinga DB issue #676[2], this is not something one might want to encourage all users to use. However, there are definitely setups where this option might come in handy. [0]: https://redis.io/docs/latest/commands/select/ [1]: https://github.com/Icinga/icinga2/blob/bca1a8447af26313123183efa863f947f9590731/lib/icingadb/icingadb.ti#L23 [2]: Icinga/icingadb#676
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 would also change GetAddr()
to include the database index, if other than 0
. In Icinga DB, we are using that function to log where we connect to.
I like the idea, but the
How about introducing a new method for both
EDIT: I did a thing in #53. |
The idea of a more informative connection information string was brought up in #50[0]. Currently, at least Icinga DB and Icinga Notifications are logging their connection target after startup. This information, however, is quite vague and was now extended to contain, e.g., if TLS is used, the username, the database. > INFO icingadb Connecting to database at "localhost:3306" as user "icingadb" against database "icingadb" as "mysql" > INFO icingadb Connecting to Redis at "localhost:6380" as user "foo" against database 7 The previously used method GetAddr does, however, not really represent the required information. That's why it was removed and the fmt.Stringer was implemented. This makes a small change necessary after updating the icinga-go-library, like: ``` - logger.Infof("Connecting to database at '%s'", db.GetAddr()) + logger.Infof("Connecting to database at %s", db) ``` [0] #50 (review)
I will write something there and we can leave this PR as it is. |
The idea of a more informative connection information string was brought up in #50[0]. Currently, at least Icinga DB and Icinga Notifications are logging their connection target after startup. This information, however, is quite vague and was now extended to contain, e.g., if TLS is used, the username, the database. > INFO icingadb Connecting to database at 'mysql://icingadb@localhost:3306/icingadb' > INFO icingadb Connecting to Redis at 'redis://localhost:6380' Furthermore, the zapcore.ObjectMarshaler interface was implemented, allowing both *db.DB and *redis.Client to be used as a zap logging field, showing the address. [0] #50 (review)
A Redis server might support multiple databases, allowing to use the same Redis for different applications. The database can either be configured for the configuration or later changed via SELECT. By default, the database 0 will be used.
While both the used go-redis library and even Icinga 2 support this feature, we should expose this here and make this configurable.
As discussed in Icinga DB issue #676, this is not something one might want to encourage all users to use. However, there are definitely setups where this option might come in handy.