-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
15 changed files
with
177 additions
and
30 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
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
7 changes: 7 additions & 0 deletions
7
source/TransactionalBox.InboxWorker.Kafka/Internals/IInboxWorkerKafkaSettings.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,7 @@ | ||
namespace TransactionalBox.InboxWorker.Kafka.Internals | ||
{ | ||
internal interface IInboxWorkerKafkaSettings | ||
{ | ||
string BootstrapServers { get; } | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
source/TransactionalBox.InboxWorker.Kafka/Internals/KafkaConfigFactory.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,40 @@ | ||
using Confluent.Kafka; | ||
using TransactionalBox.Internals; | ||
|
||
namespace TransactionalBox.InboxWorker.Kafka.Internals | ||
{ | ||
internal sealed class KafkaConfigFactory | ||
{ | ||
private readonly ITransactionalBoxSettings _transactionalBoxSettings; | ||
|
||
private readonly IInboxWorkerKafkaSettings _inboxWorkerKafkaSettings; | ||
|
||
private ConsumerConfig? _config = null; | ||
|
||
public KafkaConfigFactory( | ||
ITransactionalBoxSettings transactionalBoxSettings, | ||
IInboxWorkerKafkaSettings inboxWorkerKafkaSettings) | ||
{ | ||
_transactionalBoxSettings = transactionalBoxSettings; | ||
_inboxWorkerKafkaSettings = inboxWorkerKafkaSettings; | ||
} | ||
|
||
internal ConsumerConfig Create() | ||
{ | ||
if (_config is not null) | ||
{ | ||
return _config; | ||
} | ||
|
||
_config = new ConsumerConfig() | ||
{ | ||
GroupId = _transactionalBoxSettings.ServiceName, | ||
BootstrapServers = _inboxWorkerKafkaSettings.BootstrapServers, | ||
AutoOffsetReset = AutoOffsetReset.Earliest, | ||
EnableAutoCommit = false, | ||
}; | ||
|
||
return _config; | ||
} | ||
} | ||
} |
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
11 changes: 11 additions & 0 deletions
11
source/TransactionalBox.InboxWorker.Kafka/Settings/InboxWorkerKafkaSettings.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,11 @@ | ||
using TransactionalBox.InboxWorker.Kafka.Internals; | ||
|
||
namespace TransactionalBox.InboxWorker.Kafka.Settings | ||
{ | ||
public sealed class InboxWorkerKafkaSettings : IInboxWorkerKafkaSettings | ||
{ | ||
public string BootstrapServers { get; set; } | ||
|
||
internal InboxWorkerKafkaSettings() { } | ||
Check warning on line 9 in source/TransactionalBox.InboxWorker.Kafka/Settings/InboxWorkerKafkaSettings.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
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
7 changes: 7 additions & 0 deletions
7
source/TransactionalBox.OutboxWorker.Kafka/Internals/IOutboxWorkerKafkaSettings.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,7 @@ | ||
namespace TransactionalBox.OutboxWorker.Kafka.Internals | ||
{ | ||
internal interface IOutboxWorkerKafkaSettings | ||
{ | ||
string BootstrapServers { get; } | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
source/TransactionalBox.OutboxWorker.Kafka/Internals/KafkaConfigFactory.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,38 @@ | ||
using Confluent.Kafka; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace TransactionalBox.OutboxWorker.Kafka.Internals | ||
{ | ||
internal sealed class KafkaConfigFactory | ||
{ | ||
private readonly IOutboxWorkerKafkaSettings _outboxWorkerKafkaSettings; | ||
|
||
private ProducerConfig? _config = null; | ||
|
||
public KafkaConfigFactory(IOutboxWorkerKafkaSettings outboxWorkerKafkaSettings) | ||
{ | ||
_outboxWorkerKafkaSettings = outboxWorkerKafkaSettings; | ||
} | ||
|
||
internal ProducerConfig Create() | ||
{ | ||
if (_config is not null) | ||
{ | ||
return _config; | ||
} | ||
|
||
_config = new ProducerConfig() | ||
{ | ||
BootstrapServers = _outboxWorkerKafkaSettings.BootstrapServers, | ||
ClientId = Dns.GetHostName(), // TODO (HostNameService) #25 | ||
}; | ||
|
||
return _config; | ||
} | ||
} | ||
} |
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
6 changes: 4 additions & 2 deletions
6
source/TransactionalBox.OutboxWorker.Kafka/Settings/OutboxWorkerKafkaSettings.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
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
7 changes: 7 additions & 0 deletions
7
source/TransactionalBox/Internals/ITransactionalBoxSettings.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,7 @@ | ||
namespace TransactionalBox.Internals | ||
{ | ||
public interface ITransactionalBoxSettings | ||
{ | ||
string ServiceName { get; } | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
source/TransactionalBox/Settings/TransactionalBoxSettings.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,11 @@ | ||
using TransactionalBox.Internals; | ||
|
||
namespace TransactionalBox.Settings | ||
{ | ||
public sealed class TransactionalBoxSettings : ITransactionalBoxSettings | ||
{ | ||
public string ServiceName { get; set; } | ||
|
||
internal TransactionalBoxSettings() { } | ||
Check warning on line 9 in source/TransactionalBox/Settings/TransactionalBoxSettings.cs
|
||
} | ||
} |