-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b026bc2
commit 2aedb54
Showing
5 changed files
with
54 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,5 @@ RequeueTesterProducer/obj/Debug/net7.0/ | |
RequeueTesterProducer/obj/ | ||
|
||
ReQueue/bin/Debug/ | ||
|
||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using StackExchange.Redis; | ||
|
||
namespace ReQueue; | ||
|
||
public class ConnectionHub | ||
{ | ||
private readonly ConnectionMultiplexer _connectionMultiplexer; | ||
private readonly IDatabase _db; | ||
|
||
/// <summary> | ||
/// Initialize a new connection hub instance. | ||
/// </summary> | ||
/// <param name="connectionString">The connection string of the redis database to use.</param> | ||
/// <param name="dbnumber">The number of the database to use.</param> | ||
/// <exception cref="ArgumentNullException"></exception> | ||
public ConnectionHub(string connectionString, int dbnumber = 0) | ||
{ | ||
if (string.IsNullOrEmpty(connectionString)) | ||
{ | ||
throw new ArgumentNullException(nameof(connectionString)); | ||
} | ||
_connectionMultiplexer = ConnectionMultiplexer.Connect(connectionString); | ||
_db = _connectionMultiplexer.GetDatabase(dbnumber); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new queue of the specified type. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the queue to create.</typeparam> | ||
/// <returns>A message queue object of specified type.</returns> | ||
public MessageQueue<T> GetMessageQueue<T>() | ||
{ | ||
return new MessageQueue<T>(_db); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters