Skip to content

Commit 14dc219

Browse files
committed
Add --simulations=N parameter to seqcli sample ingest
1 parent 5ba0f2a commit 14dc219

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/Roastery/Program.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ public static async Task Main(ILogger logger, CancellationToken cancellationToke
2828
new RequestLoggingMiddleware(webApplicationLogger,
2929
new SchedulingLatencyMiddleware(
3030
new FaultInjectionMiddleware(webApplicationLogger,
31-
new Router(new Controller[]
32-
{
31+
new Router([
3332
new OrdersController(logger, database),
3433
new ProductsController(logger, database)
35-
}, webApplicationLogger))))));
34+
], webApplicationLogger))))));
3635

3736
var agents = new List<Agent>();
3837

src/SeqCli/Cli/Commands/Sample/IngestCommand.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
using System;
16+
using System.Linq;
1617
using System.Threading.Tasks;
1718
using SeqCli.Cli.Features;
1819
using SeqCli.Connection;
@@ -31,6 +32,7 @@ class IngestCommand : Command
3132
readonly BatchSizeFeature _batchSize;
3233

3334
bool _quiet;
35+
int _simulations = 1;
3436

3537
public IngestCommand(SeqConnectionFactory connectionFactory)
3638
{
@@ -39,6 +41,8 @@ public IngestCommand(SeqConnectionFactory connectionFactory)
3941
_connection = Enable<ConnectionFeature>();
4042

4143
Options.Add("quiet", "Don't echo ingested events to `STDOUT`", _ => _quiet = true);
44+
Options.Add("simulations=", "Number of concurrent simulations to run; the default runs a single simulation",
45+
v => _simulations = int.Parse(v));
4246

4347
_batchSize = Enable<BatchSizeFeature>();
4448
}
@@ -55,7 +59,12 @@ protected override async Task<int> Run()
5559
}
5660

5761
var connection = _connectionFactory.Connect(_connection);
58-
await Simulation.RunAsync(connection, apiKey, batchSize, echoToStdout: !_quiet);
62+
var simulations = Enumerable.Range(0, _simulations)
63+
.Select(_ => Simulation.RunAsync(connection, apiKey, batchSize, echoToStdout: !_quiet))
64+
.ToList();
65+
66+
await Task.WhenAll(simulations);
67+
5968
return 0;
6069
}
6170
}

src/SeqCli/Sample/Loader/Simulation.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static async Task RunAsync(SeqConnection connection, string? apiKey, int
3535
.CreateLogger();
3636

3737
var ship = Task.Run(() => LogShipper.ShipEvents(connection, apiKey, buffer,
38-
InvalidDataHandling.Fail, SendFailureHandling.Continue, batchSize));
38+
InvalidDataHandling.Fail, SendFailureHandling.Continue, batchSize), cancellationToken);
3939

4040
await Roastery.Program.Main(logger, cancellationToken);
4141
await logger.DisposeAsync();

0 commit comments

Comments
 (0)