Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Billing/Billing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NServiceBus" Version="9.0.0" />
<PackageReference Include="NServiceBus.Heartbeat" Version="5.0.0" />
<PackageReference Include="NServiceBus.Metrics.ServiceControl" Version="5.0.0" />
<PackageReference Include="NServiceBus" Version="9.*" />
<PackageReference Include="NServiceBus.Heartbeat" Version="5.*" />
<PackageReference Include="NServiceBus.Metrics.ServiceControl" Version="5.*" />
</ItemGroup>

</Project>
45 changes: 12 additions & 33 deletions src/Billing/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
using Microsoft.Extensions.DependencyInjection;
using Shared;

Console.Title = "Failure rate (Billing)";
Console.SetWindowSize(65, 15);

LoggingUtils.ConfigureLogging("Billing");

var endpointConfiguration = new EndpointConfiguration("Billing");
Expand All @@ -29,10 +26,13 @@
endpointConfiguration.AuditProcessedMessagesTo("audit");
endpointConfiguration.SendHeartbeatTo("Particular.ServiceControl");

var instanceId = "1C62248E-2681-45A4-B44D-5CF93584BAD6";
endpointConfiguration.UniquelyIdentifyRunningInstance()
.UsingCustomIdentifier(new Guid("1C62248E-2681-45A4-B44D-5CF93584BAD6"))
.UsingCustomIdentifier(new Guid(instanceId))
.UsingCustomDisplayName("original-instance");

endpointConfiguration.ConfigureOpenTelemetry("Sales", instanceId, 9120);

var metrics = endpointConfiguration.EnableMetrics();
metrics.SendMetricDataToServiceControl(
"Particular.Monitoring",
Expand All @@ -41,38 +41,17 @@

var simulationEffects = new SimulationEffects();
endpointConfiguration.RegisterComponents(cc => cc.AddSingleton(simulationEffects));
endpointConfiguration.Recoverability().OnConsecutiveFailures(5, new RateLimitSettings(TimeSpan.FromSeconds(5)));

var endpointInstance = await Endpoint.Start(endpointConfiguration);

RunUserInterfaceLoop(simulationEffects);
var nonInteractive = args.Length > 1 && args[1] == bool.FalseString;
var interactive = !nonInteractive;

await endpointInstance.Stop();

void RunUserInterfaceLoop(SimulationEffects state)
UserInterface.RunLoop("Failure rate (Billing)", new Dictionary<char, (string, Action)>
{
while (true)
{
Console.Clear();
Console.WriteLine("Billing Endpoint");
Console.WriteLine("Press F to increase the simulated failure rate");
Console.WriteLine("Press S to decrease the simulated failure rate");
Console.WriteLine("Press ESC to quit");
Console.WriteLine();

state.WriteState(Console.Out);
['w'] = ("increase the simulated failure rate", () => simulationEffects.IncreaseFailureRate()),
['s'] = ("decrease the simulated failure rate", () => simulationEffects.DecreaseFailureRate())
}, writer => simulationEffects.WriteState(writer), interactive);

var input = Console.ReadKey(true);

switch (input.Key)
{
case ConsoleKey.F:
state.IncreaseFailureRate();
break;
case ConsoleKey.S:
state.DecreaseFailureRate();
break;
case ConsoleKey.Escape:
return;
}
}
}
await endpointInstance.Stop();
6 changes: 3 additions & 3 deletions src/ClientUI/ClientUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NServiceBus" Version="9.0.0" />
<PackageReference Include="NServiceBus.Heartbeat" Version="5.0.0" />
<PackageReference Include="NServiceBus.Metrics.ServiceControl" Version="5.0.0" />
<PackageReference Include="NServiceBus" Version="9.*" />
<PackageReference Include="NServiceBus.Heartbeat" Version="5.*" />
<PackageReference Include="NServiceBus.Metrics.ServiceControl" Version="5.*" />
</ItemGroup>

</Project>
41 changes: 11 additions & 30 deletions src/ClientUI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
using Messages;
using Shared;

Console.Title = "Load (ClientUI)";
Console.SetWindowSize(65, 15);

LoggingUtils.ConfigureLogging("ClientUI");

var endpointConfiguration = new EndpointConfiguration("ClientUI");
Expand All @@ -24,10 +21,13 @@
endpointConfiguration.AuditProcessedMessagesTo("audit");
endpointConfiguration.SendHeartbeatTo("Particular.ServiceControl");

var instanceId = "EA3E7D1B-8171-4098-B160-1FEA975CCB2C";
endpointConfiguration.UniquelyIdentifyRunningInstance()
.UsingCustomIdentifier(new Guid("EA3E7D1B-8171-4098-B160-1FEA975CCB2C"))
.UsingCustomIdentifier(new Guid(instanceId))
.UsingCustomDisplayName("original-instance");

endpointConfiguration.ConfigureOpenTelemetry("Sales", instanceId, 9130);

var metrics = endpointConfiguration.EnableMetrics();
metrics.SendMetricDataToServiceControl(
"Particular.Monitoring",
Expand All @@ -43,35 +43,16 @@
var cancellation = new CancellationTokenSource();
var simulatedWork = simulatedCustomers.Run(cancellation.Token);

RunUserInterfaceLoop(simulatedCustomers);
var nonInteractive = args.Length > 1 && args[1] == bool.FalseString;
var interactive = !nonInteractive;

UserInterface.RunLoop("Load (ClientUI)", new Dictionary<char, (string, Action)>
{
['c'] = ("toggle High/Low traffic mode", () => simulatedCustomers.ToggleTrafficMode()),
}, writer => simulatedCustomers.WriteState(writer), interactive);

cancellation.Cancel();

await simulatedWork;

await endpointInstance.Stop();

void RunUserInterfaceLoop(SimulatedCustomers simulatedCustomers)
{
while (true)
{
Console.Clear();
Console.WriteLine("Simulating customers placing orders on a website");
Console.WriteLine("Press T to toggle High/Low traffic mode");
Console.WriteLine("Press ESC to quit");
Console.WriteLine();

simulatedCustomers.WriteState(Console.Out);

var input = Console.ReadKey(true);

switch (input.Key)
{
case ConsoleKey.T:
simulatedCustomers.ToggleTrafficMode();
break;
case ConsoleKey.Escape:
return;
}
}
}
29 changes: 22 additions & 7 deletions src/MonitoringDemo/DemoLauncher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

sealed class DemoLauncher : IDisposable
{
public DemoLauncher()
readonly bool remoteControlMode;

public DemoLauncher(bool remoteControlMode)
{
demoJob = new Job("Particular.MonitoringDemo");
this.remoteControlMode = remoteControlMode;
demoJob = new Job("Particular.MonitoringDemo", remoteControlMode);

File.WriteAllText(@".\Marker.sln", string.Empty);
}
Expand All @@ -28,6 +31,14 @@ public void Dispose()
DirectoryEx.ForceDeleteReadonly(".audit-db");
}

public void Send(string value)
{
demoJob.Send(billingPath, 0, value);
demoJob.Send(shippingPath, 0, value);
demoJob.Send(clientPath, 0, value);
demoJob.Send(salesPath, 0, value);
}

public void Platform()
{
if (disposed)
Expand All @@ -45,7 +56,7 @@ public void Billing()
return;
}

demoJob.AddProcess(Path.Combine("Billing", "Billing.exe"));
demoJob.AddProcess(billingPath);
}

public void Shipping()
Expand All @@ -55,7 +66,7 @@ public void Shipping()
return;
}

demoJob.AddProcess(Path.Combine("Shipping", "Shipping.exe"));
demoJob.AddProcess(shippingPath);
}

public void ScaleOutSales()
Expand All @@ -65,7 +76,7 @@ public void ScaleOutSales()
return;
}

demoJob.AddProcess(Path.Combine("Sales", "Sales.exe"));
demoJob.AddProcess(salesPath);
}

public void ScaleInSales()
Expand All @@ -75,7 +86,7 @@ public void ScaleInSales()
return;
}

demoJob.KillProcess(Path.Combine("Sales", "Sales.exe"));
demoJob.KillProcess(salesPath);
}

public void ClientUI()
Expand All @@ -85,9 +96,13 @@ public void ClientUI()
return;
}

demoJob.AddProcess(Path.Combine("ClientUI", "ClientUI.exe"));
demoJob.AddProcess(clientPath);
}

readonly Job demoJob;
private bool disposed;
private static readonly string billingPath = Path.Combine("Billing", "Billing.exe");
private static readonly string shippingPath = Path.Combine("Shipping", "Shipping.exe");
private static readonly string salesPath = Path.Combine("Sales", "Sales.exe");
private static readonly string clientPath = Path.Combine("ClientUI", "ClientUI.exe");
}
Loading