Skip to content

Commit b32ce79

Browse files
committed
Allow queue to publish a lambda command
1 parent 8369675 commit b32ce79

File tree

5 files changed

+25
-10
lines changed

5 files changed

+25
-10
lines changed

src/InEngine.Core/Queuing/Clients/DatabaseClient.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Data;
44
using System.Data.SqlClient;
55
using System.Linq;
6+
using InEngine.Core.Commands;
67
using InEngine.Core.Exceptions;
78
using InEngine.Core.Queuing.Clients.Database;
89
using Newtonsoft.Json;
@@ -32,6 +33,11 @@ public void Publish(ICommand command)
3233
}
3334
}
3435

36+
public void Publish(Action action)
37+
{
38+
Publish(new Lambda() { Action = action });
39+
}
40+
3541
public bool Consume()
3642
{
3743

src/InEngine.Core/Queuing/Clients/FileClient.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
5+
using InEngine.Core.Commands;
56
using InEngine.Core.Exceptions;
67

78
namespace InEngine.Core.Queuing.Clients
@@ -58,6 +59,11 @@ public void Publish(ICommand command)
5859
}
5960
}
6061

62+
public void Publish(Action action)
63+
{
64+
Publish(new Lambda() { Action = action });
65+
}
66+
6167
public bool Consume()
6268
{
6369
var fileInfo = new DirectoryInfo(PendingQueuePath)

src/InEngine.Core/Queuing/Clients/RedisClient.cs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4-
using System.Reflection;
5-
using System.Threading.Tasks;
4+
using InEngine.Core.Commands;
65
using InEngine.Core.Exceptions;
7-
using Newtonsoft.Json;
86
using StackExchange.Redis;
97

108
namespace InEngine.Core.Queuing.Clients
@@ -27,16 +25,15 @@ public class RedisClient : IQueueClient
2725
});
2826
public static ConnectionMultiplexer Connection { get { return lazyConnection.Value; } }
2927
public ConnectionMultiplexer _connectionMultiplexer;
30-
public IDatabase Redis
31-
{
32-
get
33-
{
34-
return Connection.GetDatabase(RedisDb);
35-
}
36-
}
28+
public IDatabase Redis { get { return Connection.GetDatabase(RedisDb); } }
3729
public bool UseCompression { get; set; }
3830
public int RedisDb { get; set; }
3931

32+
public void Publish(Action action)
33+
{
34+
Publish(new Lambda() { Action = action });
35+
}
36+
4037
public void Publish(ICommand command)
4138
{
4239
Redis.ListLeftPush(

src/InEngine.Core/Queuing/IQueueClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public interface IQueueClient
99
string QueueName { get; set; }
1010
bool UseCompression { get; set; }
1111
void Publish(ICommand command);
12+
void Publish(Action action);
1213
bool Consume();
1314
long GetPendingQueueLength();
1415
long GetInProgressQueueLength();

src/InEngine.Core/Queuing/Queue.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ public static Queue Make(bool useSecondaryQueue = false)
4949
return queue;
5050
}
5151

52+
public void Publish(Action action)
53+
{
54+
QueueClient.Publish(action);
55+
}
56+
5257
public void Publish(ICommand command)
5358
{
5459
QueueClient.Publish(command);

0 commit comments

Comments
 (0)