mirror of
https://github.com/meysamhadeli/booking-microservices.git
synced 2026-04-24 14:28:09 +08:00
fix: Fix bug event-store for load configuration options
This commit is contained in:
parent
f10fc930d6
commit
4fee16e3b8
190
.github/workflows/ci.yml
vendored
190
.github/workflows/ci.yml
vendored
@ -19,51 +19,51 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
#
|
|
||||||
# - name: Build and Test Flight
|
- name: Build and Test Flight
|
||||||
# uses: ./.github/actions/build-test
|
uses: ./.github/actions/build-test
|
||||||
# if: success()
|
if: success()
|
||||||
# id: build-test-flight-step
|
id: build-test-flight-step
|
||||||
# with:
|
with:
|
||||||
# project-path: 'src/Services/Flight/src/Flight.Api'
|
project-path: 'src/Services/Flight/src/Flight.Api'
|
||||||
# tests-path: 'src/Services/Flight/tests/'
|
tests-path: 'src/Services/Flight/tests/'
|
||||||
# # wildcard search for files with the ".cobertura.xml" extension in all subdirectories of the current directory
|
# wildcard search for files with the ".cobertura.xml" extension in all subdirectories of the current directory
|
||||||
# # https://www.jamescroft.co.uk/combining-multiple-code-coverage-results-in-azure-devops/
|
# https://www.jamescroft.co.uk/combining-multiple-code-coverage-results-in-azure-devops/
|
||||||
# # https://stackoverflow.com/questions/53255065/dotnet-unit-test-with-coverlet-how-to-get-coverage-for-entire-solution-and-not
|
# https://stackoverflow.com/questions/53255065/dotnet-unit-test-with-coverlet-how-to-get-coverage-for-entire-solution-and-not
|
||||||
# reports-path: ${{ github.workspace }}/**/*.cobertura.xml
|
reports-path: ${{ github.workspace }}/**/*.cobertura.xml
|
||||||
# reports-output-path: ${{ github.workspace }}/output/test-results
|
reports-output-path: ${{ github.workspace }}/output/test-results
|
||||||
# service-name: 'Flight'
|
service-name: 'Flight'
|
||||||
# token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
#
|
|
||||||
# - name: Build and Test Identity
|
- name: Build and Test Identity
|
||||||
# uses: ./.github/actions/build-test
|
uses: ./.github/actions/build-test
|
||||||
# if: success()
|
if: success()
|
||||||
# id: build-test-identity-step
|
id: build-test-identity-step
|
||||||
# with:
|
with:
|
||||||
# project-path: 'src/Services/Identity/src/Identity.Api'
|
project-path: 'src/Services/Identity/src/Identity.Api'
|
||||||
# tests-path: 'src/Services/Identity/tests/'
|
tests-path: 'src/Services/Identity/tests/'
|
||||||
# # wildcard search for files with the ".cobertura.xml" extension in all subdirectories of the current directory
|
# wildcard search for files with the ".cobertura.xml" extension in all subdirectories of the current directory
|
||||||
# # https://www.jamescroft.co.uk/combining-multiple-code-coverage-results-in-azure-devops/
|
# https://www.jamescroft.co.uk/combining-multiple-code-coverage-results-in-azure-devops/
|
||||||
# # https://stackoverflow.com/questions/53255065/dotnet-unit-test-with-coverlet-how-to-get-coverage-for-entire-solution-and-not
|
# https://stackoverflow.com/questions/53255065/dotnet-unit-test-with-coverlet-how-to-get-coverage-for-entire-solution-and-not
|
||||||
# reports-path: ${{ github.workspace }}/**/*.cobertura.xml
|
reports-path: ${{ github.workspace }}/**/*.cobertura.xml
|
||||||
# reports-output-path: ${{ github.workspace }}/output/test-results
|
reports-output-path: ${{ github.workspace }}/output/test-results
|
||||||
# service-name: 'Identity'
|
service-name: 'Identity'
|
||||||
# token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
#
|
|
||||||
# - name: Build and Test Passenger
|
- name: Build and Test Passenger
|
||||||
# uses: ./.github/actions/build-test
|
uses: ./.github/actions/build-test
|
||||||
# if: success()
|
if: success()
|
||||||
# id: build-test-passenger-step
|
id: build-test-passenger-step
|
||||||
# with:
|
with:
|
||||||
# project-path: 'src/Services/Passenger/src/Passenger.Api'
|
project-path: 'src/Services/Passenger/src/Passenger.Api'
|
||||||
# tests-path: 'src/Services/Passenger/tests/'
|
tests-path: 'src/Services/Passenger/tests/'
|
||||||
# # wildcard search for files with the ".cobertura.xml" extension in all subdirectories of the current directory
|
# wildcard search for files with the ".cobertura.xml" extension in all subdirectories of the current directory
|
||||||
# # https://www.jamescroft.co.uk/combining-multiple-code-coverage-results-in-azure-devops/
|
# https://www.jamescroft.co.uk/combining-multiple-code-coverage-results-in-azure-devops/
|
||||||
# # https://stackoverflow.com/questions/53255065/dotnet-unit-test-with-coverlet-how-to-get-coverage-for-entire-solution-and-not
|
# https://stackoverflow.com/questions/53255065/dotnet-unit-test-with-coverlet-how-to-get-coverage-for-entire-solution-and-not
|
||||||
# reports-path: ${{ github.workspace }}/**/*.cobertura.xml
|
reports-path: ${{ github.workspace }}/**/*.cobertura.xml
|
||||||
# reports-output-path: ${{ github.workspace }}/output/test-results
|
reports-output-path: ${{ github.workspace }}/output/test-results
|
||||||
# service-name: 'Passenger'
|
service-name: 'Passenger'
|
||||||
# token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and Test Booking
|
- name: Build and Test Booking
|
||||||
uses: ./.github/actions/build-test
|
uses: ./.github/actions/build-test
|
||||||
@ -80,53 +80,53 @@ jobs:
|
|||||||
service-name: 'Booking'
|
service-name: 'Booking'
|
||||||
token: ${{ secrets.GITHUB_TOKEN }}
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
# - name: Update Release Drafter
|
- name: Update Release Drafter
|
||||||
# if: ${{ github.ref == 'refs/heads/main' && success() }}
|
if: ${{ github.ref == 'refs/heads/main' && success() }}
|
||||||
# id: last_release
|
id: last_release
|
||||||
# uses: release-drafter/release-drafter@v5
|
uses: release-drafter/release-drafter@v5
|
||||||
# env:
|
env:
|
||||||
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
#
|
|
||||||
# - name: Release Version Info
|
- name: Release Version Info
|
||||||
# run:
|
run:
|
||||||
# echo "Release version is:" ${{ steps.last_release.outputs.tag_name }}
|
echo "Release version is:" ${{ steps.last_release.outputs.tag_name }}
|
||||||
#
|
|
||||||
# - name: Build and Publish Identity to Docker
|
- name: Build and Publish Identity to Docker
|
||||||
# if: ${{ github.ref == 'refs/heads/main' && success() }}
|
if: ${{ github.ref == 'refs/heads/main' && success() }}
|
||||||
# uses: ./.github/actions/docker-build-publish
|
uses: ./.github/actions/docker-build-publish
|
||||||
# with:
|
with:
|
||||||
# tag-name: ${{ steps.last_release.outputs.tag_name }}
|
tag-name: ${{ steps.last_release.outputs.tag_name }}
|
||||||
# registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
|
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
# registry-password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
registry-password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
# dockerfile-path: 'src/Services/Identity/Dockerfile'
|
dockerfile-path: 'src/Services/Identity/Dockerfile'
|
||||||
# image-name: 'booking-microservices-identity'
|
image-name: 'booking-microservices-identity'
|
||||||
#
|
|
||||||
# - name: Build and Publish Flight to Docker
|
- name: Build and Publish Flight to Docker
|
||||||
# if: ${{ github.ref == 'refs/heads/main' && success() }}
|
if: ${{ github.ref == 'refs/heads/main' && success() }}
|
||||||
# uses: ./.github/actions/docker-build-publish
|
uses: ./.github/actions/docker-build-publish
|
||||||
# with:
|
with:
|
||||||
# tag-name: ${{ steps.last_release.outputs.tag_name }}
|
tag-name: ${{ steps.last_release.outputs.tag_name }}
|
||||||
# registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
|
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
# registry-password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
registry-password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
# dockerfile-path: 'src/Services/Flight/Dockerfile'
|
dockerfile-path: 'src/Services/Flight/Dockerfile'
|
||||||
# image-name: 'booking-microservices-flight'
|
image-name: 'booking-microservices-flight'
|
||||||
#
|
|
||||||
# - name: Build and Publish Passenger to Docker
|
- name: Build and Publish Passenger to Docker
|
||||||
# if: ${{ github.ref == 'refs/heads/main' && success() }}
|
if: ${{ github.ref == 'refs/heads/main' && success() }}
|
||||||
# uses: ./.github/actions/docker-build-publish
|
uses: ./.github/actions/docker-build-publish
|
||||||
# with:
|
with:
|
||||||
# tag-name: ${{ steps.last_release.outputs.tag_name }}
|
tag-name: ${{ steps.last_release.outputs.tag_name }}
|
||||||
# registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
|
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
# registry-password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
registry-password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
# dockerfile-path: 'src/Services/Passenger/Dockerfile'
|
dockerfile-path: 'src/Services/Passenger/Dockerfile'
|
||||||
# image-name: 'booking-microservices-passenger'
|
image-name: 'booking-microservices-passenger'
|
||||||
#
|
|
||||||
# - name: Build and Publish Booking to Docker
|
- name: Build and Publish Booking to Docker
|
||||||
# if: ${{ github.ref == 'refs/heads/main' && success() }}
|
if: ${{ github.ref == 'refs/heads/main' && success() }}
|
||||||
# uses: ./.github/actions/docker-build-publish
|
uses: ./.github/actions/docker-build-publish
|
||||||
# with:
|
with:
|
||||||
# tag-name: ${{ steps.last_release.outputs.tag_name }}
|
tag-name: ${{ steps.last_release.outputs.tag_name }}
|
||||||
# registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
|
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
# registry-password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
registry-password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
# dockerfile-path: 'src/Services/Booking/Dockerfile'
|
dockerfile-path: 'src/Services/Booking/Dockerfile'
|
||||||
# image-name: 'booking-microservices-booking'
|
image-name: 'booking-microservices-booking'
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using BuildingBlocks.EventStoreDB.BackgroundWorkers;
|
using BuildingBlocks.EventStoreDB.BackgroundWorkers;
|
||||||
using BuildingBlocks.EventStoreDB.Events;
|
|
||||||
using BuildingBlocks.EventStoreDB.Projections;
|
using BuildingBlocks.EventStoreDB.Projections;
|
||||||
using BuildingBlocks.EventStoreDB.Repository;
|
using BuildingBlocks.EventStoreDB.Repository;
|
||||||
using BuildingBlocks.EventStoreDB.Subscriptions;
|
using BuildingBlocks.EventStoreDB.Subscriptions;
|
||||||
@ -11,26 +10,30 @@ using Microsoft.Extensions.Logging;
|
|||||||
|
|
||||||
namespace BuildingBlocks.EventStoreDB;
|
namespace BuildingBlocks.EventStoreDB;
|
||||||
|
|
||||||
public class EventStoreDBConfig
|
using Web;
|
||||||
|
|
||||||
|
public class EventStoreOptions
|
||||||
{
|
{
|
||||||
public string ConnectionString { get; set; } = default!;
|
public string ConnectionString { get; set; } = default!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public record EventStoreDBOptions(
|
public record EventStoreDBOptions(
|
||||||
bool UseInternalCheckpointing = true
|
bool UseInternalCheckpointing = true
|
||||||
);
|
);
|
||||||
|
|
||||||
public static class EventStoreDBConfigExtensions
|
public static class EventStoreDBConfigExtensions
|
||||||
{
|
{
|
||||||
private const string DefaultConfigKey = "EventStore";
|
|
||||||
|
|
||||||
public static IServiceCollection AddEventStoreDB(this IServiceCollection services, IConfiguration config,
|
public static IServiceCollection AddEventStoreDB(this IServiceCollection services, IConfiguration config,
|
||||||
EventStoreDBOptions? options = null)
|
EventStoreDBOptions? options = null)
|
||||||
{
|
{
|
||||||
var eventStoreDBConfig = config.GetSection(DefaultConfigKey).Get<EventStoreDBConfig>();
|
|
||||||
|
|
||||||
services
|
services
|
||||||
.AddSingleton(new EventStoreClient(EventStoreClientSettings.Create(eventStoreDBConfig.ConnectionString)))
|
.AddSingleton(x=>
|
||||||
|
{
|
||||||
|
var eventStoreOptions = services.GetOptions<EventStoreOptions>(nameof(EventStoreOptions));
|
||||||
|
return new EventStoreClient(EventStoreClientSettings.Create(eventStoreOptions.ConnectionString));
|
||||||
|
})
|
||||||
.AddScoped(typeof(IEventStoreDBRepository<>), typeof(EventStoreDBRepository<>))
|
.AddScoped(typeof(IEventStoreDBRepository<>), typeof(EventStoreDBRepository<>))
|
||||||
.AddTransient<EventStoreDBSubscriptionToAll, EventStoreDBSubscriptionToAll>();
|
.AddTransient<EventStoreDBSubscriptionToAll, EventStoreDBSubscriptionToAll>();
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,8 @@ using Microsoft.Extensions.DependencyInjection;
|
|||||||
|
|
||||||
namespace BuildingBlocks.EventStoreDB;
|
namespace BuildingBlocks.EventStoreDB;
|
||||||
|
|
||||||
|
using Web;
|
||||||
|
|
||||||
public static class Extensions
|
public static class Extensions
|
||||||
{
|
{
|
||||||
// ref: https://github.com/oskardudycz/EventSourcing.NetCore/tree/main/Sample/EventStoreDB/ECommerce
|
// ref: https://github.com/oskardudycz/EventSourcing.NetCore/tree/main/Sample/EventStoreDB/ECommerce
|
||||||
@ -13,6 +15,8 @@ public static class Extensions
|
|||||||
params Assembly[] assemblies
|
params Assembly[] assemblies
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
services.AddValidateOptions<EventStoreOptions>();
|
||||||
|
|
||||||
var assembliesToScan = assemblies.Length > 0 ? assemblies : new[] { Assembly.GetEntryAssembly()! };
|
var assembliesToScan = assemblies.Length > 0 ? assemblies : new[] { Assembly.GetEntryAssembly()! };
|
||||||
|
|
||||||
return services
|
return services
|
||||||
|
|||||||
@ -278,7 +278,7 @@ public class TestFixture<TEntryPoint> : IAsyncLifetime
|
|||||||
.ToString(NumberFormatInfo.InvariantInfo)),
|
.ToString(NumberFormatInfo.InvariantInfo)),
|
||||||
new("MongoOptions:ConnectionString", MongoDbTestContainer.GetConnectionString()),
|
new("MongoOptions:ConnectionString", MongoDbTestContainer.GetConnectionString()),
|
||||||
new("MongoOptions:DatabaseName", TestContainers.MongoContainerConfiguration.Name),
|
new("MongoOptions:DatabaseName", TestContainers.MongoContainerConfiguration.Name),
|
||||||
new("EventStore:ConnectionString", EventStoreDbTestContainer.GetConnectionString())
|
new("EventStoreOptions:ConnectionString", EventStoreDbTestContainer.GetConnectionString())
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"ConnectionString": "Server=postgres;Port=5432;Database=persist_message;User Id=postgres;Password=postgres;Include Error Detail=true"
|
"ConnectionString": "Server=postgres;Port=5432;Database=persist_message;User Id=postgres;Password=postgres;Include Error Detail=true"
|
||||||
},
|
},
|
||||||
"EventStore": {
|
"EventStoreOptions": {
|
||||||
"ConnectionString": "esdb://eventstore:2113?tls=false"
|
"ConnectionString": "esdb://eventstore:2113?tls=false"
|
||||||
},
|
},
|
||||||
"MongoOptions": {
|
"MongoOptions": {
|
||||||
|
|||||||
@ -48,7 +48,7 @@
|
|||||||
"BreakDuration" : 30
|
"BreakDuration" : 30
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"EventStore": {
|
"EventStoreOptions": {
|
||||||
"ConnectionString": "esdb://localhost:2113?tls=false"
|
"ConnectionString": "esdb://localhost:2113?tls=false"
|
||||||
},
|
},
|
||||||
"MongoOptions": {
|
"MongoOptions": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user