Skip to content

Commit 3e3c468

Browse files
Improved refactoring
1 parent 917ce9f commit 3e3c468

File tree

30 files changed

+233
-171
lines changed

30 files changed

+233
-171
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<ImplicitUsings>enable</ImplicitUsings>
55
<Nullable>enable</Nullable>
66
<IsPackable>true</IsPackable>
7-
<Version>2.2.69</Version>
7+
<Version>2.2.71</Version>
88
<Authors>Andrey Serdyuk</Authors>
99
<Company>TaskHub</Company>
1010
<Title>TaskHub.Shared - Reusable Primitives for .NET Microservices</Title>

README.md

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,63 @@ TaskHub.Shared contains the fundamental components and patterns used across all
1313
- **TaskHub.Shared.Primitives** — Core value objects, identifiers, and base types shared across all domains.
1414
- **TaskHub.Shared.Domain** — Base entities, aggregates, domain events, and helpers for implementing rich domain models.
1515
- **TaskHub.Shared.Response** — Unified result system (`Result`, `ValueResult<T>`, `ResultFactory`) for consistent success/error handling.
16-
17-
- **TaskHub.Shared.Commands.Abstractions** — Abstractions for the command pipeline (interfaces for command handlers, behaviors, buses).
18-
19-
- **TaskHub.Shared.Commands.Bus** — Default in-process command bus implementation with behavior orchestration (behaviors pipeline, cross-cutting concerns).
20-
16+
- **TaskHub.Shared.Services.Abstractions** — Common service interfaces for dependency inversion.
2117
- **TaskHub.Shared.Events.Abstractions** — Domain event abstractions for cross-service communication and eventual consistency patterns.
2218

19+
## Persistence
2320
- **TaskHub.Shared.Persistence.Abstractions** — Interfaces for read/write repositories, unit of work, and persistence contracts.
2421
- **TaskHub.Shared.Infrastructure.EfCore** — EF Core helpers, base configurations, and interceptors for database integration.
2522

2623
- **TaskHub.Shared.Redis** — Integration with Redis for caching and distributed state management.
27-
- **TaskHub.Shared.RateLimiter** — Reusable rate-limiting primitives and policies for protecting APIs and internal pipelines.
2824

25+
## Authorization
2926
- **TaskHub.Shared.Authorization.Abstractions** — Authorization contracts, roles/permissions abstractions, and policies shared across services.
3027
- **TaskHub.Shared.Authorization.Identity** — Identity-related models and helpers used by TaskHub services (users, claims, roles).
3128

32-
- **TaskHub.Shared.Swagger** — Common Swagger / OpenAPI configuration for ASP.NET Core services (conventions, filters, defaults).
29+
30+
## Tools
3331
- **TaskHub.Shared.Versioning** — Shared conventions and helpers for API versioning across TaskHub microservices.
34-
- **TaskHub.Shared.ConfigurationTools** — Utilities for configuration binding, validation, and environment-specific configuration setup.
35-
- **TaskHub.Shared.Bootstraper** — Opinionated startup helpers to compose TaskHub modules into a microservice with minimal boilerplate.
32+
- **TaskHub.Shared.RateLimiter** — Reusable rate-limiting primitives and policies for protecting APIs and internal pipelines.
3633

34+
35+
## Pipeline
36+
- **TaskHub.Shared.Commands.Abstractions** — Abstractions for the command pipeline (interfaces for command handlers, behaviors, buses).
37+
- **TaskHub.Shared.Commands.Bus** — Default in-process command bus implementation with behavior orchestration (behaviors pipeline, cross-cutting concerns).
38+
39+
40+
## Geocoding
3741
- **TaskHub.Shared.GeoCoding.Abstractions** — Abstractions for geocoding providers.
3842
- **TaskHub.Shared.GeoCoding.Nominatim** — Implementation of the geocoding service using the Nominatim API.
3943

40-
- **TaskHub.Observability.Metrics.Abstractions** — Abstractions and options for metrics collection (meters, counters, histograms) used across services.
41-
- **TaskHub.Observability.Metrics.Implementation** — Default metrics implementation built on top of `IMeterFactory` and OpenTelemetry metrics.
4244

45+
## Observability
4346

47+
### Metrics
48+
- **TaskHub.Observability.Metrics.Abstractions** — Abstractions and options for metrics collection (meters, counters, histograms) used across services.
49+
- **TaskHub.Observability.Metrics.Implementation** — Metrics implementation built on top of prometheus-net.
50+
51+
### Tracing
4452
- **TaskHub.Observability.Traces** — Tracing and implementation built on top of ActivitySource.
4553

54+
### Logging
55+
- **TaskHub.Observability.Logger** — Logging implementation built on top of Serilog.
4656

57+
### OpenTelemetry
4758
- **TaskHub.Observability.OpenTelemetry** — Preconfigured OpenTelemetry setup (resource, exporters, processors) for metrics, traces, and logs (Tempo, Prometheus, Loki).
4859

60+
### Refactoring
61+
- **TaskHub.Shared.Refactoring.Abstractions** — Abstractions for service refactoring.
62+
- **TaskHub.Shared.Refactoring.Implementation** — Implementations for service refactoring and dynamic dependency resolution.
63+
64+
### Swagger / OpenAPI
65+
- **TaskHub.Shared.Swagger** — Common Swagger / OpenAPI configuration for ASP.NET Core services (conventions, filters, defaults).
66+
67+
68+
## Bootstrapping
69+
- **TaskHub.Shared.Bootstraper.Basic** — Basic service bootstrapping (dependency injection, configuration, logging).
70+
- **TaskHub.Shared.Bootstraper.Full** — Comprehensive service bootstrapping (all features, advanced configuration, etc.).
71+
72+
4973
## Design Principles
5074
- **DDD & Clean Architecture** — Clear separation between abstractions and implementations.
5175
- **Lightweight by Design** — Each project compiles into a minimal, focused package.

Shared.slnx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
<Project Path="TaskHub.Shared.Authorization.Abstractions/TaskHub.Shared.Authorization.Abstractions.csproj" Id="f264dfba-c7d1-4ae9-b715-a4ae655a2b94" />
1818
<Project Path="TaskHub.Shared.Authorization.Identity/TaskHub.Shared.Authorization.Identity.csproj" Id="e504d3d9-9465-43fd-a1c8-86b896225084" />
1919
</Folder>
20+
<Folder Name="/Bootstraping/">
21+
<Project Path="TaskHub.Shared.Bootstraper.Basic/TaskHub.Shared.Bootstraper.Basic.csproj" />
22+
<Project Path="TaskHub.Shared.Bootstraper.Full/TaskHub.Shared.Bootstraper.Full.csproj" />
23+
</Folder>
2024
<Folder Name="/Commands/">
2125
<Project Path="TaskHub.Shared.Commands.Abstractions/TaskHub.Shared.Commands.Abstractions.csproj" Id="6db7c998-24a5-4b97-8aae-a3e725e04d25" />
2226
<Project Path="TaskHub.Shared.Commands.Bus/TaskHub.Shared.Commands.Bus.csproj" />
@@ -49,11 +53,10 @@
4953
<Project Path="TaskHub.Observability.Traces/TaskHub.Observability.Traces.csproj" Id="cb48c92f-bb0c-432d-a8e2-03599ef12ae4" />
5054
</Folder>
5155
<Folder Name="/Refactoring/">
52-
<Project Path="TaskHub.Shared.Refactoring/TaskHub.Shared.Refactoring.csproj" Id="6fe83e8e-6b67-48d4-a433-e52e282477ac" />
56+
<Project Path="TaskHub.Shared.Refactoring.Abstractions/TaskHub.Shared.Refactoring.Abstractions.csproj" Id="c88a066f-c702-4671-bb52-c5293696fc0c" />
57+
<Project Path="TaskHub.Shared.Refactoring.Implementation/TaskHub.Shared.Refactoring.Implementation.csproj" Id="6fe83e8e-6b67-48d4-a433-e52e282477ac" />
5358
</Folder>
5459
<Folder Name="/Tools/">
55-
<Project Path="TaskHub.Shared.Bootstraper.Basic/TaskHub.Shared.Bootstraper.Basic.csproj" />
56-
<Project Path="TaskHub.Shared.Bootstraper.Full/TaskHub.Shared.Bootstraper.Full.csproj" />
5760
<Project Path="TaskHub.Shared.RateLimiter/TaskHub.Shared.RateLimiter.csproj" Id="6e4d4c7b-0df0-460e-8653-8123bc540fc6" />
5861
<Project Path="TaskHub.Shared.Redis/TaskHub.Shared.Redis.csproj" Id="5fc5938a-a4d2-4fee-99cc-5d9cf54e0645" />
5962
<Project Path="TaskHub.Shared.Swagger/TaskHub.Shared.Swagger.csproj" Id="b945e948-fe0b-4724-8f55-cbd0be83e924" />

TaskHub.Observability.Logger/LogService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public sealed class LogService : ILogService
77
{
88
private readonly ILogger _log = Log.ForContext<LogService>();
99

10-
public void Debug(string message, object? data = null) =>
10+
public void Debug(string message, object? data = null) =>
1111
Write(LogEventLevel.Debug, message, null, data);
1212

1313
public void Info(string message, object? data = null) =>

TaskHub.Observability.Logger/SerilogBoostrap.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ namespace TaskHub.Observability.Logger;
55

66
public static class SerilogBoostrap
77
{
8-
public static IHostBuilder AddAppSerilog(this IHostBuilder host) =>
8+
public static IHostBuilder AddAppSerilog(this IHostBuilder host) =>
99
host.UseSerilog((ctx, lc) => lc.ReadFrom.Configuration(ctx.Configuration));
1010
}
Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Description>Common service interfaces for dependency inversion.</Description>
4+
</PropertyGroup>
25

3-
<PropertyGroup>
4-
<TargetFramework>net10.0</TargetFramework>
5-
<ImplicitUsings>enable</ImplicitUsings>
6-
<Nullable>enable</Nullable>
7-
</PropertyGroup>
6+
<PropertyGroup>
7+
<TargetFramework>net10.0</TargetFramework>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<Nullable>enable</Nullable>
10+
</PropertyGroup>
811

9-
<ItemGroup>
10-
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
11-
<PackageReference Include="Serilog.Settings.Configuration" Version="10.0.0" />
12-
<PackageReference Include="Serilog.Sinks.Grafana.Loki" Version="8.3.1" />
13-
</ItemGroup>
12+
<ItemGroup>
13+
<PackageReference Include="Serilog.AspNetCore" Version="10.0.0" />
14+
<PackageReference Include="Serilog.Settings.Configuration" Version="10.0.0" />
15+
<PackageReference Include="Serilog.Sinks.Grafana.Loki" Version="8.3.1" />
16+
</ItemGroup>
1417

15-
<ItemGroup>
16-
<ProjectReference Include="..\TaskHub.Shared.Services.Abstractions\TaskHub.Shared.Services.Abstractions.csproj" />
17-
</ItemGroup>
18+
<ItemGroup>
19+
<ProjectReference Include="..\TaskHub.Shared.Services.Abstractions\TaskHub.Shared.Services.Abstractions.csproj" />
20+
</ItemGroup>
1821

1922
</Project>

TaskHub.Observability.Metrics.Implementation/GaugeMetric/GaugeMetricService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public void Set(double increment, params (string key, string value)[] labels) =>
2020

2121
public void Inc(double increment, params (string key, string value)[] labels) =>
2222
ResolveLabels(labels).Inc(increment);
23-
23+
2424
public void Dec() => Metric.Dec();
2525

2626
public void Dec(double increment, params (string key, string value)[] labels) =>

TaskHub.Observability.Traces/Service/TracesService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using System.Diagnostics;
22
using System.Reflection;
33
using System.Runtime.CompilerServices;
4-
using TaskHub.Shared.Refactoring;
4+
using TaskHub.Shared.Refactoring.Abstractions;
55

66
namespace TaskHub.Observability.Traces.Service;
77

8-
public sealed class TracesService(AppInfo appInfo) : ITracesService
8+
public sealed class TracesService(ServiceInfo appInfo) : ITracesService
99
{
10-
private readonly ActivitySource Source = new(appInfo.ServiceName);
10+
private readonly ActivitySource Source = new(appInfo.Name);
1111

1212
public Activity? Current => Activity.Current;
1313

TaskHub.Observability.Traces/TaskHub.Observability.Traces.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<ProjectReference Include="..\TaskHub.Shared.Refactoring\TaskHub.Shared.Refactoring.csproj" />
13+
<ProjectReference Include="..\TaskHub.Shared.Refactoring\TaskHub.Shared.Refactoring.Implementation.csproj" />
1414
<ProjectReference Include="..\TaskHub.Shared.Services.Abstractions\TaskHub.Shared.Services.Abstractions.csproj" />
1515
</ItemGroup>
1616
</Project>

TaskHub.Shared.Authorization.Abstractions/IUserService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
using TaskHub.Shared.Primitives.ValueObjects;
2+
using TaskHub.Shared.Refactoring.Abstractions;
23
using TaskHub.Shared.Services.Abstractions;
34

45
namespace TaskHub.Shared.Authorization.Abstractions;
56

6-
[ManualRegistration]
7+
[Unresolvable]
78
public interface IUserService : IService
89
{
910
UserId UserId { get; }

0 commit comments

Comments
 (0)