Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup Label="Production">
<PackageVersion Include="Aspire.Hosting.AppHost" Version="13.0.0" />
<PackageVersion Include="Aspire.Hosting.PostgreSQL" Version="13.0.0" />
<PackageVersion Include="Aspire.Hosting.RabbitMQ" Version="13.0.0" />
<PackageVersion Include="EvolutionaryArchitecture.Fitnet.Common.Api" Version="3.2.5" />
<PackageVersion Include="EvolutionaryArchitecture.Fitnet.Common.Core" Version="3.2.5" />
<PackageVersion Include="EvolutionaryArchitecture.Fitnet.Common.Infrastructure" Version="3.2.5" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="13.0.0" />

<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
<PackageReference Include="Aspire.Hosting.PostgreSQL" />
<PackageReference Include="Aspire.Hosting.RabbitMQ" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Fitnet.Contracts\Fitnet.Contracts.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Projects;

var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("postgres")
.WithImage("postgres", "14.3")
.WithPgAdmin();

var fitnetDatabase = postgres.AddDatabase("fitnetsdb", "fitnet");

var rabbitmq = builder.AddRabbitMQ("rabbitmq")
.WithManagementPlugin();

builder.AddProject<Fitnet_Contracts>("fitnet-contracts-microservice")
.WithEnvironment("ASPNETCORE_ENVIRONMENT", "Development")
.WithReference(fitnetDatabase, "Database__ConnectionString")
.WithReference(rabbitmq, "EventBus__ConnectionString")
.WaitFor(postgres)
.WaitFor(rabbitmq);

await builder.Build().RunAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.DistributedApplication": "Information"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ internal static IServiceCollection AddEventBus(this IServiceCollection services,
return;
}

var uri = options.Value!.Uri;
var username = options.Value!.Username;
var password = options.Value!.Password;

if (!string.IsNullOrEmpty(uri))
{
factoryConfigurator.Host(uri, h =>
{
if (!string.IsNullOrEmpty(username))
{
h.Username(username);
}
if (!string.IsNullOrEmpty(password))
{
h.Password(password);
}
});
}

factoryConfigurator.ConfigureEndpoints(context);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<Project Path="Fitnet.Contracts.Infrastructure\Fitnet.Contracts.Infrastructure.csproj" Type="Classic C#" />
<Project Path="Fitnet.Contracts.IntegrationEvents\Fitnet.Contracts.IntegrationEvents.csproj" Type="Classic C#" />
<Project Path="Fitnet.Contracts\Fitnet.Contracts.csproj" Type="Classic C#" />
<Project Path="Fitnet.Contracts.AppHost\Fitnet.Contracts.AppHost.csproj" Type="Classic C#" />
</Solution>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup Label="Production">
<PackageVersion Include="Aspire.Hosting.AppHost" Version="13.0.0" />
<PackageVersion Include="Aspire.Hosting.PostgreSQL" Version="13.0.0" />
<PackageVersion Include="Dapper" Version="2.1.66" />
<PackageVersion Include="EvolutionaryArchitecture.Fitnet.Common.Api" Version="3.2.5" />
<PackageVersion Include="EvolutionaryArchitecture.Fitnet.Common.Core" Version="3.2.5" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<Sdk Name="Aspire.AppHost.Sdk" Version="13.0.0" />

<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
<PackageReference Include="Aspire.Hosting.PostgreSQL" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Fitnet\Fitnet.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Projects;

var builder = DistributedApplication.CreateBuilder(args);

var postgres = builder.AddPostgres("postgres")
.WithImage("postgres", "14.3")
.WithPgAdmin();

var fitnetDatabase = postgres.AddDatabase("fitnetsdb", "fitnet");

builder.AddProject<Fitnet>("fitnet-modular-monolith")
.WithEnvironment("ASPNETCORE_ENVIRONMENT", "Development")
.WithReference(fitnetDatabase, "Database__ConnectionString")
.WaitFor(postgres);

await builder.Build().RunAsync();
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning",
"Aspire.Hosting.DistributedApplication": "Information"
}
}
}
1 change: 1 addition & 0 deletions Chapter-3-microservice-extraction/Fitnet/Src/Fitnet.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
<Project Path="Reports\Tests\Fitnet.Reports.IntegrationTests\Fitnet.Reports.IntegrationTests.csproj" Type="Classic C#" />
</Folder>
<Project Path="Fitnet\Fitnet.csproj" Type="Classic C#" />
<Project Path="Fitnet.AppHost\Fitnet.AppHost.csproj" Type="Classic C#" />
</Solution>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ internal static IServiceCollection AddEventBus(this IServiceCollection services,
{
return;
}

var uri = options.Value!.Uri;
var username = options.Value!.Username;
var password = options.Value!.Password;

if (!string.IsNullOrEmpty(uri))
{
factoryConfigurator.Host(uri, h =>
{
if (!string.IsNullOrEmpty(username))
{
h.Username(username);
}
if (!string.IsNullOrEmpty(password))
{
h.Password(password);
}
});
}

factoryConfigurator.ConfigureEndpoints(context);
});
configurator.ConfigureOutbox();
Expand Down
36 changes: 36 additions & 0 deletions Chapter-3-microservice-extraction/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,42 @@ The `Contracts` microservice runs on port `:8081`. Please navigate to http://loc

That's it! You should now be able to run the application using either one of the above. :thumbsup:

=== Run with .NET Aspire

The Fitnet application uses .NET Aspire for local development orchestration.

==== Run Fitnet Modular Monolith

1. **Ensure Docker is running** on your machine.
2. **Navigate to the Fitnet AppHost directory:**
[source,shell]
----
cd Fitnet/Src/Fitnet.AppHost
----
3. **Run the AppHost project:**
[source,shell]
----
dotnet run
----

The Aspire Dashboard will open automatically, showing the Fitnet modular monolith and PostgreSQL database.

==== Run Fitnet.Contracts Microservice

1. **Ensure Docker is running** on your machine.
2. **Navigate to the Contracts AppHost directory:**
[source,shell]
----
cd Fitnet.Contracts/Src/Fitnet.Contracts.AppHost
----
3. **Run the AppHost project:**
[source,shell]
----
dotnet run
----

The Aspire Dashboard will open automatically, showing the Fitnet.Contracts microservice, PostgreSQL database, and RabbitMQ message broker.

=== Building and debugging code in Rider IDE

Before you build or debug code in `Rider` or `Visual Studio` IDE, you first have to provide your user name and previously generated PAT for artifactory to download packages for `Common` which is a part of this repository. When you load the solution, your IDE should request the credentials:
Expand Down
49 changes: 0 additions & 49 deletions Chapter-3-microservice-extraction/docker-compose.yml

This file was deleted.