pass q key to db methods
This commit is contained in:
@@ -9,27 +9,28 @@ namespace NOCQ
|
||||
{
|
||||
public RedisDataase(){}
|
||||
|
||||
public static async Task SaveAlert(IAlert alert)
|
||||
public static async Task SaveAlert(IAlert alert, string q)
|
||||
{
|
||||
using (var redis = new RedisClientAsync(ConfigurationManager.AppSettings["DBQueueKey"],
|
||||
using (var redis = new RedisClientAsync(q,
|
||||
Convert.ToInt32(ConfigurationManager.AppSettings["Port"]),
|
||||
Convert.ToInt32(ConfigurationManager.AppSettings["Timeout"])
|
||||
))
|
||||
{
|
||||
await redis.LPush(ConfigurationManager.AppSettings["DBQueueKey"], alert);
|
||||
await redis.LPush(q, alert);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static async Task<Alert> GetNextAlert()
|
||||
public static async Task<Alert> GetNextAlert(string q)
|
||||
{
|
||||
using (var redis = new RedisClientAsync(ConfigurationManager.AppSettings["DBQueueKey"],
|
||||
|
||||
using (var redis = new RedisClientAsync(q,
|
||||
Convert.ToInt32(ConfigurationManager.AppSettings["Port"]),
|
||||
Convert.ToInt32(ConfigurationManager.AppSettings["Timeout"])
|
||||
))
|
||||
{
|
||||
var ts = await redis.RPop(ConfigurationManager.AppSettings["DBQueueKey"]);
|
||||
var ts = await redis.RPop(q);
|
||||
|
||||
return JsonConvert.DeserializeObject<Alert>(ts);
|
||||
|
||||
|
||||
12
src/NOCQ/DB/RedisQueues.cs
Normal file
12
src/NOCQ/DB/RedisQueues.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
|
||||
namespace NOCQ
|
||||
{
|
||||
public struct RedisQueues
|
||||
{
|
||||
public static string Input = ConfigurationManager.AppSettings["DBQueueInput"];
|
||||
public static string Output = ConfigurationManager.AppSettings["DBQueueOutput"];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
<Compile Include="Model\Alert.cs" />
|
||||
<Compile Include="Plugins\Email\IParseRule.cs" />
|
||||
<Compile Include="Model\IAlert.cs" />
|
||||
<Compile Include="DB\RedisQueues.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user