ServiceMapper 1.0.0-beta.89
dotnet add package ServiceMapper --version 1.0.0-beta.89
NuGet\Install-Package ServiceMapper -Version 1.0.0-beta.89
<PackageReference Include="ServiceMapper" Version="1.0.0-beta.89" />
paket add ServiceMapper --version 1.0.0-beta.89
#r "nuget: ServiceMapper, 1.0.0-beta.89"
// Install ServiceMapper as a Cake Addin #addin nuget:?package=ServiceMapper&version=1.0.0-beta.89&prerelease // Install ServiceMapper as a Cake Tool #tool nuget:?package=ServiceMapper&version=1.0.0-beta.89&prerelease
ServiceMapper
ServiceMapper is a robust and efficient tool designed to streamline the management of service dependencies in a microservices environment. It empowers developers to designate specific classes using the IMappedService
interface and create customized service maps based on the base class and mapping strategies. This facilitates the creation of an internal architectural representation of the application, which can then generate exportable data through various exporters.
Key Features
Mapping Strategies: Develop custom strategies using the
IMappingStrategy
interface to map service dependencies and their attributes within the application, or utilize pre-built strategies provided by the library, such asDownstreamMappingStrategy
orHttpMappingStrategy
.Upstream Mapping Discovery: Utilize the ServiceMapper endpoint for upstream discovery, enabling the recursive mapping technique for downstream service dependencies. This functionality allows for comprehensive mapping and description of the microservice architecture within the application.
How do I get started?
1. Create a Mapping Strategy
ServiceMapper is built using a Strategy Design Pattern control the techniques for mapping service dependencies. There are some examples provided by the library such as the DownstreamMappingStrategy
and the HttpMappingStrategy
both of which take advantage of the Upstream Discoverability feature outlined above to call a downstream service endpoint and recursively map itself and its dependencies downstream.
To create a custom Mapping Strategy, follow these steps:
- Define a class (optionally with the suffix
Strategy
) that implements theIMappingStrategy
inteface - Using the
Map
method to define the service map returned by the mapping strategy - (Optionally) Use the Upstream Mapping Discovery feature to call a downstream service which implements this library to perform a recursive mapping technique on downstream services
public class MyMappingStrategy(string serviceName) : IMappingStrategy
{
public async Task<ServiceMap> Map(CancellationToken cancellationToken = default)
{
return await Task.FromResult(new ServiceMap
{
Name = serviceName,
IsAvailable = true
});
}
}
Follow a more detailed construction of the service map or simply return a mapped service map object for less complex services
3. Creating a Mapped Service
To create a mapped service class, follow these steps:
- Register a mapped service on the container using either the
AddScoped(bool map)
,AddTransient(bool map)
,AddSingleton(bool map)
(or explicitly withAddMappedService<T>()
) extension methods - Implement the
IMappedService
on the mapped service - Assign the chosen mapping strategy to the
MappingStrategy
property
public class MyServiceClass : IMyServiceClass, IMappedService
{
public IMappingStrategy MappingStrategy => new MyMappingStrategy(nameof(MyServiceClass));
}
services.AddTransient<IMyServiceClass, MyServiceClass>(map: true);
services.AddScoped<IMyServiceClass, MyServiceClass>(map: true);
services.AddSingleton<IMyServiceClass, MyServiceClass>(map: true);
services.AddMappedService<MyServiceClass>();
What's next?
ServiceMapper is a comprehensive library that offers a unique approach to mapping service dependencies in applications. It goes beyond traditional mapping capabilities by providing the ability to map the entire application architecture through upstream discoverability. However, this is just the tip of the iceberg.
Coming soon
In addition to its core functionality, ServiceMapper includes several exporters that enable the export of mapping data through various mediums. Notably, the ServiceMappingProtocol
exporter allows for architectural visualization of the service map using the SMP protocol. This ensures that as your application evolves, the architectural design of your domain can dynamically adapt and reflect these changes. Gone are the days of manually maintaining documentation for code changes.
For more detailed instructions and examples, please refer to the documentation in the respective directories:
- File Exporter Documentation
- Storage Exporter Documentation
- SMP Exporter Documentation (Coming soon)
Where can I get it?
First, install NuGet. Then, install ServiceMapper from the package manager console:
PM> Install-Package ServiceMapper
Or from the .NET CLI as:
dotnet add package ServiceMapper
Do you have an issue?
If you're still running into problems, please don't hesitate to file an issue in this repository. We appreciate your feedback and contributions!
License
ServiceMapper Copyright © 2024 Anthony Larner under the MIT license.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Identity.Web.DownstreamApi (>= 2.19.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|