Setting client lib name properly by wrapping multiplxer creation #420
Setting client lib name properly by wrapping multiplxer creation #420atakavci wants to merge 5 commits intoredis:masterfrom
Conversation
|
hey @slorello89 @uglide |
slorello89
left a comment
There was a problem hiding this comment.
Couple minor nits, overall LGTM 👍 - will need to update docs to reflect it as well.
src/NRedisStack/RedisClient.cs
Outdated
| /// Represents a Redis client that can connect to a Redis server | ||
| /// providing access to <see cref="IRedisDatabase"/> instances as well as the underlying multiplexer. | ||
| /// </summary> | ||
| public class RedisClient |
There was a problem hiding this comment.
This should be lifted out into an interface IRedisClient and should take an IConnectionMultiplexer in all the places.
src/NRedisStack/RedisClient.cs
Outdated
| /// <summary> | ||
| /// Creates a new <see cref="RedisClient"/> instance. | ||
| /// </summary> | ||
| /// <param name="configuration">The string configuration to use for this client.</param> |
|
|
||
| namespace NRedisStack.RedisStackCommands | ||
| { | ||
| internal class DatabaseWrapper : IDatabase |
There was a problem hiding this comment.
I'm assuming the idea here is that if we have a different opinion of how a command should be handled than StackExchange.Redis we can override it here without asking them to break?
There was a problem hiding this comment.
My main motivation here is more on keeping all commands accessible from same object/reference and keep the usage exact same compared to how it is provided with extension methods.
in the future, this might prove useful in the way you pointed out. However, I don't think we'd be inclined to interfere with how SE.Redis handles it.
There was a problem hiding this comment.
from same object/reference
from single object/reference
- add doc url for configuration
|
reviewing again, it looks like the main thing here is to add the public static class RedisDatabaseExtensions
{
public static BloomCommands BF(this IDatabase database) => new(database);
public static CuckooCommands CF(this IDatabase database) => new(database);
public static CmsCommands CMS(this IDatabase database) => new(database);
// ...
public static TimeSeriesCommands TS(this IDatabase database) => new(database);
}
...
var db = // existing SE.Redis API
var cf = db.CF();There's also C# 14 "extension members", which would allow the exact same thing, but with properties - i.e. var db = // existing SE.Redis API
var cf = db.CF;This is quite appealing from a visual perspective, as it allows things like: var db = // existing SE.Redis API
var result = db.CF.SomeMethod(args);However, C# 14 demands .NET 10 SDK, which is not GA until (at a guess, based on history) November 2025. |
|
target here, as mentioned in description, to provide a reliable way to set client lib info. Best way to implement is to get some support or callback methods from SE.Redis for sure. Since now we are to decide together and also have more resources to work on that, in case we can leverage SE.Redis directly, wrapping BTW In short, it would be very nice to see something like you mentioned here is provided and this PR gets redundant. |
Closes/Fixes #406
Current implementation for setting client lib info on connections is only working for single initial connection in the application context/runtime, which leaves the cases and setups given below out of scope;
There are couple of ways to improve the situation with setting library info on connections but all have its downsides. Here some of them with their own drawbacks;
I choose to follow the third approach since it is clear, reliable and simplistic implementation compared to other two.
In this PR there are three major types introduced, two of them is exposed in public API;
IRedisDatabase : An interface to allow access to modules commands in addition to those in IDatabase
RedisClient : Provides creation+configuration of IRedisDatabase instances
DatabaseWrapper : Underlying wrapper class to compose IDatabase and modules commands into same type.
Existing implementation with extension methods will stay (at least until a major release) and we will keep these new types as experimental, until we make sure this approach brings more benefits, allow required modifications with underlying types and complies with up-coming changes with StackExchange.Redis.