Skip to content

Commit d554cd4

Browse files
authored
Split TFCALL to TFCALL and TFCALLASYNC (#178)
1 parent 1c345ad commit d554cd4

File tree

5 files changed

+42
-15
lines changed

5 files changed

+42
-15
lines changed

src/NRedisStack/Gears/GearsCommands.cs

+18-6
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,31 @@ public static Dictionary<string, RedisResult>[] TFunctionList(this IDatabase db,
4848
}
4949

5050
/// <summary>
51-
/// Trigger a sync or async (Coroutine) function.
51+
/// Trigger a sync function.
5252
/// </summary>
5353
/// <param name="libraryName">The library name contains the function.</param>
5454
/// <param name="functionName">The function name to run.</param>
5555
/// <param name="keys">keys that will be touched by the function.</param>
5656
/// <param name="args">Additional argument to pass to the function.</param>
57-
/// <param name="async">If true, Invoke an async function (Coroutine).</param>
5857
/// <returns>The return value from the sync & async function on error in case of failure.</returns>
59-
/// <remarks><seealso href="https://redis.io/commands/tfcall"/></remarks> //TODO: check this link when it's available
60-
/// <remarks><seealso href="https://redis.io/commands/tfcallasync"/></remarks> //TODO: check this link when it's available
61-
public static RedisResult TFCall(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null, bool async = false)
58+
/// <remarks><seealso href="https://redis.io/commands/tfcall"/></remarks>
59+
public static RedisResult TFCall_(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null)
6260
{
63-
return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async));
61+
return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : false));
62+
}
63+
64+
/// <summary>
65+
/// Trigger a async (Coroutine) function.
66+
/// </summary>
67+
/// <param name="libraryName">The library name contains the function.</param>
68+
/// <param name="functionName">The function name to run.</param>
69+
/// <param name="keys">keys that will be touched by the function.</param>
70+
/// <param name="args">Additional argument to pass to the function.</param>
71+
/// <returns>The return value from the sync & async function on error in case of failure.</returns>
72+
/// <remarks><seealso href="https://redis.io/commands/tfcallasync"/></remarks>
73+
public static RedisResult TFCallAsync_(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null)
74+
{
75+
return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : true));
6476
}
6577
}
6678
}

src/NRedisStack/Gears/GearsCommandsAsync.cs

+18-5
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,31 @@ public static async Task<Dictionary<string, RedisResult>[]> TFunctionListAsync(t
4747
}
4848

4949
/// <summary>
50-
/// Invoke a sync or async (Coroutine) function.
50+
/// Trigger a sync function.
5151
/// </summary>
5252
/// <param name="libraryName">The library name contains the function.</param>
5353
/// <param name="functionName">The function name to run.</param>
5454
/// <param name="keys">keys that will be touched by the function.</param>
5555
/// <param name="args">Additional argument to pass to the function.</param>
56-
/// <param name="async">If true, Invoke an async function (Coroutine).</param>
5756
/// <returns>The return value from the sync & async function on error in case of failure.</returns>
58-
/// <remarks><seealso href="https://redis.io/commands/"/></remarks> //TODO: add link to the command when it's available
59-
public static async Task<RedisResult> TFCallAsync(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null, bool async = false)
57+
/// <remarks><seealso href="https://redis.io/commands/tfcall"/></remarks>
58+
public async static Task<RedisResult> TFCall_Async(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null)
59+
{
60+
return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : false));
61+
}
62+
63+
/// <summary>
64+
/// Trigger a async (Coroutine) function.
65+
/// </summary>
66+
/// <param name="libraryName">The library name contains the function.</param>
67+
/// <param name="functionName">The function name to run.</param>
68+
/// <param name="keys">keys that will be touched by the function.</param>
69+
/// <param name="args">Additional argument to pass to the function.</param>
70+
/// <returns>The return value from the sync & async function on error in case of failure.</returns>
71+
/// <remarks><seealso href="https://redis.io/commands/tfcallasync"/></remarks>
72+
public async static Task<RedisResult> TFCallAsync_Async(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null)
6073
{
61-
return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async));
74+
return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : true));
6275
}
6376
}
6477
}

src/NRedisStack/Graph/IGraphCommands.cs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace NRedisStack
55
{
6+
[Obsolete("RedisGraph is not supported since Redis 7.2 (https://redis.com/blog/redisgraph-eol/)")]
67
public interface IGraphCommands
78
{
89
/// <summary>

src/NRedisStack/Graph/IGraphCommandsAsync.cs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace NRedisStack
55
{
6+
[Obsolete("RedisGraph is not supported since Redis 7.2 (https://redis.com/blog/redisgraph-eol/)")]
67
public interface IGraphCommandsAsync
78
{
89
/// <summary>

tests/NRedisStack.Tests/Gears/GearsTests.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public void TestTFCall()
103103
TryDeleteLib(db, "lib", "lib1", "lib2", "lib3");
104104

105105
Assert.True(db.TFunctionLoad(GenerateLibCode("lib")));
106-
Assert.Equal("bar", db.TFCall("lib", "foo", async: false).ToString());
107-
Assert.Equal("bar", db.TFCall("lib", "foo", async: true).ToString());
106+
Assert.Equal("bar", db.TFCall_("lib", "foo").ToString());
107+
Assert.Equal("bar", db.TFCallAsync_("lib", "foo").ToString());
108108

109109
Assert.True(db.TFunctionDelete("lib"));
110110
}
@@ -117,8 +117,8 @@ public async Task TestTFCallAsync()
117117
TryDeleteLib(db, "lib", "lib1", "lib2", "lib3");
118118

119119
Assert.True(await db.TFunctionLoadAsync(GenerateLibCode("lib")));
120-
Assert.Equal("bar", (await db.TFCallAsync("lib", "foo", async: false)).ToString());
121-
Assert.Equal("bar", (await db.TFCallAsync("lib", "foo", async: true)).ToString());
120+
Assert.Equal("bar", (await db.TFCall_Async("lib", "foo")).ToString());
121+
Assert.Equal("bar", (await db.TFCallAsync_Async("lib", "foo")).ToString());
122122

123123
Assert.True(await db.TFunctionDeleteAsync("lib"));
124124
}

0 commit comments

Comments
 (0)