Skip to content

Commit

Permalink
Merge branch 'master' into Issue174/DeprecatedGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
chayim authored Sep 3, 2023
2 parents 7bff035 + d554cd4 commit 7635b52
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
24 changes: 18 additions & 6 deletions src/NRedisStack/Gears/GearsCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,31 @@ public static Dictionary<string, RedisResult>[] TFunctionList(this IDatabase db,
}

/// <summary>
/// Trigger a sync or async (Coroutine) function.
/// Trigger a sync function.
/// </summary>
/// <param name="libraryName">The library name contains the function.</param>
/// <param name="functionName">The function name to run.</param>
/// <param name="keys">keys that will be touched by the function.</param>
/// <param name="args">Additional argument to pass to the function.</param>
/// <param name="async">If true, Invoke an async function (Coroutine).</param>
/// <returns>The return value from the sync & async function on error in case of failure.</returns>
/// <remarks><seealso href="https://redis.io/commands/tfcall"/></remarks> //TODO: check this link when it's available
/// <remarks><seealso href="https://redis.io/commands/tfcallasync"/></remarks> //TODO: check this link when it's available
public static RedisResult TFCall(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null, bool async = false)
/// <remarks><seealso href="https://redis.io/commands/tfcall"/></remarks>
public static RedisResult TFCall_(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null)
{
return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async));
return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : false));
}

/// <summary>
/// Trigger a async (Coroutine) function.
/// </summary>
/// <param name="libraryName">The library name contains the function.</param>
/// <param name="functionName">The function name to run.</param>
/// <param name="keys">keys that will be touched by the function.</param>
/// <param name="args">Additional argument to pass to the function.</param>
/// <returns>The return value from the sync & async function on error in case of failure.</returns>
/// <remarks><seealso href="https://redis.io/commands/tfcallasync"/></remarks>
public static RedisResult TFCallAsync_(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null)
{
return db.Execute(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : true));
}
}
}
23 changes: 18 additions & 5 deletions src/NRedisStack/Gears/GearsCommandsAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,31 @@ public static async Task<Dictionary<string, RedisResult>[]> TFunctionListAsync(t
}

/// <summary>
/// Invoke a sync or async (Coroutine) function.
/// Trigger a sync function.
/// </summary>
/// <param name="libraryName">The library name contains the function.</param>
/// <param name="functionName">The function name to run.</param>
/// <param name="keys">keys that will be touched by the function.</param>
/// <param name="args">Additional argument to pass to the function.</param>
/// <param name="async">If true, Invoke an async function (Coroutine).</param>
/// <returns>The return value from the sync & async function on error in case of failure.</returns>
/// <remarks><seealso href="https://redis.io/commands/"/></remarks> //TODO: add link to the command when it's available
public static async Task<RedisResult> TFCallAsync(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null, bool async = false)
/// <remarks><seealso href="https://redis.io/commands/tfcall"/></remarks>
public async static Task<RedisResult> TFCall_Async(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null)
{
return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : false));
}

/// <summary>
/// Trigger a async (Coroutine) function.
/// </summary>
/// <param name="libraryName">The library name contains the function.</param>
/// <param name="functionName">The function name to run.</param>
/// <param name="keys">keys that will be touched by the function.</param>
/// <param name="args">Additional argument to pass to the function.</param>
/// <returns>The return value from the sync & async function on error in case of failure.</returns>
/// <remarks><seealso href="https://redis.io/commands/tfcallasync"/></remarks>
public async static Task<RedisResult> TFCallAsync_Async(this IDatabase db, string libraryName, string functionName, string[]? keys = null, string[]? args = null)
{
return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async));
return await db.ExecuteAsync(GearsCommandBuilder.TFCall(libraryName, functionName, keys, args, async : true));
}
}
}
3 changes: 2 additions & 1 deletion src/NRedisStack/Graph/IGraphCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

namespace NRedisStack
{
[Obsolete("RedisGraph supported is deprecated as of Redis Stack 7.2 (https://redis.com/blog/redisgraph-eol/)")]

[Obsolete("RedisGraph support is deprecated as of Redis Stack 7.2 (https://redis.com/blog/redisgraph-eol/)")]
public interface IGraphCommands
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/NRedisStack/Graph/IGraphCommandsAsync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace NRedisStack
{
[Obsolete("RedisGraph supported is deprecated as of Redis Stack 7.2 (https://redis.com/blog/redisgraph-eol/)")]
[Obsolete("RedisGraph support is deprecated as of Redis Stack 7.2 (https://redis.com/blog/redisgraph-eol/)")]
public interface IGraphCommandsAsync
{
/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions tests/NRedisStack.Tests/Gears/GearsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ public void TestTFCall()
TryDeleteLib(db, "lib", "lib1", "lib2", "lib3");

Assert.True(db.TFunctionLoad(GenerateLibCode("lib")));
Assert.Equal("bar", db.TFCall("lib", "foo", async: false).ToString());
Assert.Equal("bar", db.TFCall("lib", "foo", async: true).ToString());
Assert.Equal("bar", db.TFCall_("lib", "foo").ToString());
Assert.Equal("bar", db.TFCallAsync_("lib", "foo").ToString());

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

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

Assert.True(await db.TFunctionDeleteAsync("lib"));
}
Expand Down

0 comments on commit 7635b52

Please sign in to comment.