-
Notifications
You must be signed in to change notification settings - Fork 284
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
Provide a convenience string overload for connectRedisDB #1852
base: master
Are you sure you want to change the base?
Conversation
redis/vibe/db/redis/redis.d
Outdated
@@ -33,6 +33,7 @@ import std.utf; | |||
*/ | |||
RedisClient connectRedis(string host, ushort port = RedisClient.defaultPort) | |||
{ | |||
assert(!host.startsWith("redis://")); |
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.
This should leave a message what's wrong and why it's wrong for the user because this is a public function.
Something like host must be a valid IP or domain, but not an URI
redis/vibe/db/redis/redis.d
Outdated
@@ -33,6 +33,7 @@ import std.utf; | |||
*/ | |||
RedisClient connectRedis(string host, ushort port = RedisClient.defaultPort) | |||
{ | |||
assert(!host.startsWith("redis://", "Host must be a valid IP or domain, but not an URI.")); |
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.
We could also think about parsing the host
URL if the user accidentally called the wrong function, but imho it's better to use an error message here, because if the user has a full redis URI, he should have called connectRedisDB
which returns a RedisDatabase
and not only a RedisClient
Added the error message to the |
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 never use redis (always mongodb) so I'm not sure about how consistent the getDatabase(0)
part is with other implementations/apis but otherwise this LGTM as it is a pretty simple change
It's the default database like Mongo's default default. Anyhow, in case it wasn't clear this just unifies the API with how the analog vibe.d/mongodb/vibe/db/mongo/mongo.d Lines 77 to 91 in 892e094
Ping @s-ludwig |
Split-off from #1842