Skip to content

Commit

Permalink
Merge pull request #41 from a-sharifov/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
a-sharifov committed Feb 29, 2024
2 parents 49dd111 + d37dec3 commit 40a7aab
Show file tree
Hide file tree
Showing 173 changed files with 1,772 additions and 399 deletions.
21 changes: 21 additions & 0 deletions Eshop.sln
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Email.MessageBus", "crs\Ser
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Idenitty.Grpc", "crs\Services\Identity\Idenitty.Grpc\Idenitty.Grpc.csproj", "{1DEB0D00-7A0F-4F76-85CA-75E2DDA390B5}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Catalog.MessageBus", "crs\Services\Catalog\Catalog.MessageBus\Catalog.MessageBus.csproj", "{CE14C952-F456-4632-A73B-AA5F63BB646A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basket.Domain", "crs\Services\Basket\Basket.Domain\Basket.Domain.csproj", "{6A9BF2B3-9B6D-43AC-996E-4CCCA5269922}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Basket.Persistence", "crs\Services\Basket\Basket.Persistence\Basket.Persistence.csproj", "{DD696AF3-2BD3-43A8-B7B8-A3CD1BE9A46C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -205,6 +211,18 @@ Global
{1DEB0D00-7A0F-4F76-85CA-75E2DDA390B5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DEB0D00-7A0F-4F76-85CA-75E2DDA390B5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DEB0D00-7A0F-4F76-85CA-75E2DDA390B5}.Release|Any CPU.Build.0 = Release|Any CPU
{CE14C952-F456-4632-A73B-AA5F63BB646A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE14C952-F456-4632-A73B-AA5F63BB646A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE14C952-F456-4632-A73B-AA5F63BB646A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE14C952-F456-4632-A73B-AA5F63BB646A}.Release|Any CPU.Build.0 = Release|Any CPU
{6A9BF2B3-9B6D-43AC-996E-4CCCA5269922}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A9BF2B3-9B6D-43AC-996E-4CCCA5269922}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A9BF2B3-9B6D-43AC-996E-4CCCA5269922}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A9BF2B3-9B6D-43AC-996E-4CCCA5269922}.Release|Any CPU.Build.0 = Release|Any CPU
{DD696AF3-2BD3-43A8-B7B8-A3CD1BE9A46C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD696AF3-2BD3-43A8-B7B8-A3CD1BE9A46C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD696AF3-2BD3-43A8-B7B8-A3CD1BE9A46C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD696AF3-2BD3-43A8-B7B8-A3CD1BE9A46C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -248,6 +266,9 @@ Global
{9767E75F-8186-4BBE-A81A-E18B1F4687D8} = {1B13E7AE-01B6-4092-9DD0-1D53F6906791}
{492C4BC4-B89A-4E5C-B9F0-FC7A03BFE1FB} = {7CFB86E0-426D-4822-A84E-D2BC5987D187}
{1DEB0D00-7A0F-4F76-85CA-75E2DDA390B5} = {1B13E7AE-01B6-4092-9DD0-1D53F6906791}
{CE14C952-F456-4632-A73B-AA5F63BB646A} = {708EB78A-1D36-4F33-8171-3BC0ADF1C669}
{6A9BF2B3-9B6D-43AC-996E-4CCCA5269922} = {9DF0F008-D19B-4AB9-848F-9C2CB7B759CC}
{DD696AF3-2BD3-43A8-B7B8-A3CD1BE9A46C} = {9DF0F008-D19B-4AB9-848F-9C2CB7B759CC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {383EFC19-58A6-4418-98E0-23BD0341BA42}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
/// <summary>
/// Abstract class for aggregate root.
/// </summary>
/// <typeparam name="StrongestId"> The strongest id type.</typeparam>
public class AggregateRoot<StrongestId> : Entity<StrongestId>
where StrongestId : IStrongestId
/// <typeparam name="TStrongestId"> The strongest id type.</typeparam>
public abstract class AggregateRoot<TStrongestId> : Entity<TStrongestId>
where TStrongestId : IStrongestId
{
/// <summary>
/// Initializes a new instance of the <see cref="AggregateRoot{StrongestId}"/> class.
Expand All @@ -16,5 +16,5 @@ public class AggregateRoot<StrongestId> : Entity<StrongestId>
/// Initializes a new instance of the <see cref="AggregateRoot{StrongestId}"/> class.
/// </summary>
/// <param name="id"> The id.</param>
protected AggregateRoot(StrongestId id) : base(id) { }
protected AggregateRoot(TStrongestId id) : base(id) { }
}
7 changes: 1 addition & 6 deletions crs/CommonComponents/Common/Domain/Primitives/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public abstract class Entity<TStrongestId>
/// <summary>
/// Gets the domain events.
/// </summary>
public IReadOnlyCollection<IDomainEvent> DomainEvents => _domainEvents.ToList();
public IReadOnlyCollection<IDomainEvent> DomainEvents => _domainEvents.AsReadOnly();

/// <summary>
/// Add a domain event.
Expand All @@ -57,11 +57,6 @@ public override bool Equals(object? obj)
return false;
}

if(obj.GetType() != GetType())
{
return false;
}

if(obj is not Entity<TStrongestId> entity)
{
return false;
Expand Down
5 changes: 4 additions & 1 deletion crs/CommonComponents/Common/Domain/Primitives/Enumeration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ public abstract class Enumeration<TEnum>(int value, string name)

private static readonly Dictionary<int, TEnum> _enumerations = GetEnumerations();

public static TEnum? FromValue(int value) =>
public static TEnum? FromValueOrDefault(int value) =>
_enumerations.TryGetValue(value, out var enumeration)
? enumeration : null;

public static TEnum FromName(string name) =>
_enumerations.Values.Single(x => x.Name == name);

public static TEnum? FromNameOrDefault(string name) =>
_enumerations.Values.SingleOrDefault(x => x.Name == name);

public static IEnumerable<string> GetNames() =>
_enumerations.Values.Select(x => x.Name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public interface IDomainEvent : INotification
/// Gets the id of the event.
/// </summary>
Guid Id { get; }
}
}
9 changes: 7 additions & 2 deletions crs/CommonComponents/Common/Domain/Primitives/IUnitOfWork .cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public interface IUnitOfWork
/// </summary>
/// <param name="cancellationToken"> The <see cref="CancellationToken" />.</param>
/// <returns> A <see cref="Task"/> representing the asynchronous operation.</returns>
Task<int> SaveChangesAsync(CancellationToken cancellationToken = default);
int SaveChanges();
Task<int> CommitAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Gets the database context.
/// </summary>
/// <returns> The <see cref="int"/>.</returns>
int Commit();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public async Task InvokeAsync(HttpContext context)
}
catch (Exception ex)
{
_logger.LogError(ex, ex.Message);
_logger.LogError(ex, "the error: {0}", ex.Message);

var problemDetails = new ProblemDetails
{
Status = StatusCodes.Status500InternalServerError,
Expand Down
2 changes: 1 addition & 1 deletion crs/CommonComponents/Contracts/Contracts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<ItemGroup>
<Protobuf Include="Abstractions\Abstractions.proto" GrpcServices="Both" />
<Protobuf Include="Services\Identity\identity.v1.proto" GrpcServices="Both" />
<Protobuf Include="Services\Identity\identity.proto" GrpcServices="Both" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package identity.v1;
package identity.protobuf;

service IdentityService {
rpc GetUserInfo(GetUserRequest) returns (UserInfo);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/// <summary>
/// Base interfase for event bus.
/// </summary>
public interface IMessageBus
public interface IMessageBusBase
{
/// <summary>
/// Publish event to the bus.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<ItemGroup>
<ProjectReference Include="..\..\Common\Common.csproj" />
<ProjectReference Include="..\EventBus.Common\EventBus.Common.csproj" />
<ProjectReference Include="..\EventBus.MassTransit\EventBus.MassTransit.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
global using MassTransit;
global using EventBus.Common.Abstractions;
global using EventBus.MassTransit.Abstractions;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ public sealed class EventBusRabitMQ(IBusControl busControl) : IMessageBus
{
await _busControl.Send(command, cancellationToken);
}

public async Task<ISendEndpoint> GetSendEndpoint(Uri address)
{
return await _busControl.GetSendEndpoint(address);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace EventBus.MassTransit.Abstractions;

/// <summary>
/// The message bus interface.
/// </summary>
public interface IMessageBus : IMessageBusBase
{
/// <summary>
/// Get send endpoint by address.
/// </summary>
/// <param name="address"> The address.</param>
/// <returns> The <see cref="ISendEndpoint"/>.</returns>
Task<ISendEndpoint> GetSendEndpoint(Uri address);
}
5 changes: 3 additions & 2 deletions crs/Docker/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
AUTH_ISSUER=https://localhost:8081
WEB_AUDIENCE=https://localhost:7061
AUTH_ISSUER=http://identity.app
IDENTITY_GRPC_URL=http://identity.app:81
WEB_AUDIENCE=http://catalog.app
JWT_SECURITY_KEY=86A7B43F17CA48BEE7519EB8D6BDBA2SNSD

INFLUXDB_USER=admin
Expand Down
30 changes: 15 additions & 15 deletions crs/Docker/docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ version: "3.4"
services:
catalog.app:
environment:
- ASPNETCORE_URLS=http://+:80
- ASPNETCORE_HTTP_PORTS=7060
- ASPNETCORE_HTTP_PORTS=80
- ASPNETCORE_ENVIRONMENT=Development
# Custom environment variables
- REDIS_PASSWORD=${REDIS_PASSWORD}
Expand All @@ -14,6 +13,9 @@ services:
- AUTH_ISSUER=${AUTH_ISSUER}
- WEB_AUDIENCE=${WEB_AUDIENCE}
- JWT_SECURITY_KEY=${JWT_SECURITY_KEY}
- RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
- IDENTITY_GRPC_URL=${IDENTITY_GRPC_URL}
volumes:
- ${APPDATA}\microsoft\UserSecrets\:/root/.microsoft/usersecrets
- ${USERPROFILE}\.aspnet\https:/root/.aspnet/https/
Expand All @@ -22,9 +24,9 @@ services:

identity.app:
environment:
- ASPNETCORE_URLS=http://+:80
- ASPNETCORE_HTTP_PORTS=8080
- ASPNETCORE_HTTP_PORTS=80
- ASPNETCORE_ENVIRONMENT=Development
# - Kestrel__EndpointDefaults__Protocols=Http2
# Custom environment variables
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
Expand All @@ -34,6 +36,8 @@ services:
- JWT_SECURITY_KEY=${JWT_SECURITY_KEY}
- RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
- HTTP_PORT=80
- GRPC_PORT=81
ports:
- 8080:80
volumes:
Expand All @@ -42,8 +46,7 @@ services:

monitoring.app:
environment:
- ASPNETCORE_URLS=http://+:80
- ASPNETCORE_HTTP_PORTS=5065
- ASPNETCORE_HTTP_PORTS=80
- ASPNETCORE_ENVIRONMENT=Development
# Custom environment variables
- HealthChecksUI__HealthChecks__0__Name=Catalog API
Expand All @@ -59,9 +62,8 @@ services:

gateways.web:
environment:
- ASPNETCORE_URL=http://+:80;https://+:443
- ASPNETCORE_HTTP_PORTS=5039
- ASPNETCORE_HTTPS_PORTS=5040
- ASPNETCORE_HTTP_PORTS=80
- ASPNETCORE_HTTPS_PORTS=443
- ASPNETCORE_ENVIRONMENT=Development
# Custom environment variables
- [email protected]
Expand All @@ -73,29 +75,27 @@ services:
- ${APPDATA}\microsoft\UserSecrets\:/root/.microsoft/usersecrets
- ${USERPROFILE}\.aspnet\https:/root/.aspnet/https/


email.app:
environment:
- ASPNETCORE_URLS=http://+:80
- ASPNETCORE_HTTP_PORTS=5110
- ASPNETCORE_HTTP_PORTS=80
- ASPNETCORE_ENVIRONMENT=Development
# Custom environment variables
- Email__From=${EMAIL_FROM}}
- Email__Host=${EMAIL_HOST}
- Email__Port=${EMAIL_PORT}
- Email__Username=${EMAIL_USERNAME}
- Email__Password=${EMAIL_PASSWORD}
- Retry__Message__Send__Count=3
- Email__RetryMessageSendCount=3
- IdentityEndpoint__BaseUrl=${AUTH_ISSUER}}
- RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
- AUTH_ISSUER=${AUTH_ISSUER}
- WEB_AUDIENCE=${WEB_AUDIENCE}
- JWT_SECURITY_KEY=${JWT_SECURITY_KEY}
- IDENTITY_GRPC_URL=${IDENTITY_GRPC_URL}
ports:
- "5110:80"



mssql:
environment:
- ACCEPT_EULA=Y
Expand Down
20 changes: 20 additions & 0 deletions crs/Docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,23 @@ services:
networks:
web_services_network:
driver: bridge


# eventstore:
# container_name: eventstore
# image: eventstore/eventstore:21.2.0-buster-slim
# restart: unless-stopped
# environment:
# - EVENTSTORE_CLUSTER_SIZE=1
# - EVENTSTORE_RUN_PROJECTIONS=All
# - EVENTSTORE_START_STANDARD_PROJECTIONS=true
# - EVENTSTORE_EXT_TCP_PORT=1113
# - EVENTSTORE_EXT_HTTP_PORT=2113
# - EVENTSTORE_INSECURE=true
# - EVENTSTORE_ENABLE_EXTERNAL_TCP=true
# - EVENTSTORE_ENABLE_ATOM_PUB_OVER_HTTP=true
# ports:
# - '1113:1113'
# - '2113:2113'
# networks:
# - booking
13 changes: 13 additions & 0 deletions crs/Services/Basket/Basket.Domain/Basket.Domain.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\CommonComponents\Common\Common.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 40a7aab

Please sign in to comment.