-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tomasz Maruszak <maruszaktomasz@gmail.com>
- Loading branch information
Showing
14 changed files
with
179 additions
and
113 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
16 changes: 16 additions & 0 deletions
16
src/SlimMessageBus.Host.Outbox.Sql/Adapters/GuidOutboxMessage.cs
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,16 @@ | ||
namespace SlimMessageBus.Host.Outbox.Sql; | ||
|
||
public class GuidOutboxMessage : OutboxMessage, IEquatable<GuidOutboxMessage> | ||
{ | ||
public Guid Id { get; set; } | ||
|
||
public override string ToString() => Id.ToString(); | ||
|
||
public override bool Equals(object obj) | ||
=> Equals(obj as GuidOutboxMessage); | ||
|
||
public bool Equals(GuidOutboxMessage other) | ||
=> other is not null && Id.Equals(other.Id); | ||
|
||
public override int GetHashCode() => Id.GetHashCode(); | ||
} |
29 changes: 29 additions & 0 deletions
29
src/SlimMessageBus.Host.Outbox.Sql/Adapters/GuidOutboxMessageAdapter.cs
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,29 @@ | ||
namespace SlimMessageBus.Host.Outbox.Sql; | ||
|
||
public class GuidOutboxMessageAdapter(SqlOutboxTemplate sqlOutboxTemplate) : IOutboxMessageAdapter | ||
{ | ||
public OutboxMessage Create() | ||
=> new GuidOutboxMessage | ||
{ | ||
Id = Guid.NewGuid() | ||
}; | ||
|
||
public OutboxMessage Create(SqlDataReader reader, int idOrdinal) | ||
=> new GuidOutboxMessage | ||
{ | ||
Id = reader.GetGuid(idOrdinal) | ||
}; | ||
|
||
public SqlParameter CreateIdSqlParameter(string parameterName, OutboxMessage outboxMessage) | ||
{ | ||
var guidOutboxMessage = (GuidOutboxMessage)outboxMessage; | ||
return new SqlParameter(parameterName, SqlDbType.UniqueIdentifier) { Value = guidOutboxMessage.Id }; | ||
} | ||
|
||
public SqlParameter CreateIdsSqlParameter(string parameterName, IEnumerable<OutboxMessage> outboxMessages) | ||
{ | ||
var guidIds = outboxMessages.Cast<GuidOutboxMessage>().Select(x => x.Id); | ||
var idsString = string.Join(sqlOutboxTemplate.InIdsSeparator, guidIds); | ||
return new SqlParameter(parameterName, SqlDbType.NVarChar) { Value = guidIds }; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/SlimMessageBus.Host.Outbox.Sql/Adapters/IOutboxMessageAdapter.cs
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,12 @@ | ||
namespace SlimMessageBus.Host.Outbox.Sql; | ||
|
||
/// <summary> | ||
/// Allows to customize the outbox message creation and handling (PK type, etc). | ||
/// </summary> | ||
public interface IOutboxMessageAdapter | ||
{ | ||
OutboxMessage Create(); | ||
OutboxMessage Create(SqlDataReader reader, int idOrdinal); | ||
SqlParameter CreateIdSqlParameter(string parameterName, OutboxMessage outboxMessage); | ||
SqlParameter CreateIdsSqlParameter(string parameterName, IEnumerable<OutboxMessage> outboxMessages); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,4 @@ | |
|
||
public interface ISqlOutboxRepository : IOutboxRepository | ||
{ | ||
} | ||
} |
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
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
Oops, something went wrong.