ServiceMapper 1.0.0-alpha.66

This is a prerelease version of ServiceMapper.
dotnet add package ServiceMapper --version 1.0.0-alpha.66
NuGet\Install-Package ServiceMapper -Version 1.0.0-alpha.66
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ServiceMapper" Version="1.0.0-alpha.66" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ServiceMapper --version 1.0.0-alpha.66
#r "nuget: ServiceMapper, 1.0.0-alpha.66"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install ServiceMapper as a Cake Addin
#addin nuget:?package=ServiceMapper&version=1.0.0-alpha.66&prerelease

// Install ServiceMapper as a Cake Tool
#tool nuget:?package=ServiceMapper&version=1.0.0-alpha.66&prerelease

ServiceMapper

CI/CD for ServiceMapper CI/CD for ServiceMapper.Exporter.File CI/CD for ServiceMapper.Exporter.Storage

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 as DownstreamMappingStrategy or HttpMappingStrategy.

  • Service Maps: Leverage the default ServiceMap base class to define the characteristics of a given service type, or create derived classes to incorporate additional properties through polymorphic serialization (e.g. DownstreamServiceMap or DatabaseServiceMap).

  • 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 Service Map

To create a Service Map, follow these steps:

  • Define a class that inherits from the ServiceMap base class
  • Declare the custom attributes for your chosen service map class

Here's an example of creating a Service Map using the ServiceMap base class:

public class MyServiceMap : ServiceMap
{
    // Define your custom properties here for serialization
}

Note: The base class ServiceMap contains generic common attributes such as name, IsAvailable and a recursive Dependencies property for mapping service dependencies

2. 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 the IMappingStrategy 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 MyServiceMap
        {
            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 with AddMappedService<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:

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on ServiceMapper:

Package Downloads
ServiceMapper.Exporter.File

A powerful and efficient NuGet package designed to streamline the management of service dependencies in a microservices environment.

ServiceMapper.Exporter.Storage

A powerful and efficient NuGet package designed to streamline the management of service dependencies in a microservices environment.

ServiceMapper.Exporter.InMemory

Package Description

ServiceMapper.Exporter.ServiceMappingProtocol

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0-alpha.66 23 7/3/2024
1.0.0-alpha.64 16 7/3/2024
1.0.0-alpha.53 26 7/2/2024
1.0.0-alpha.52 27 6/30/2024
1.0.0-alpha.51 37 6/30/2024
1.0.0-alpha.50 36 6/29/2024
1.0.0-alpha.49 28 6/29/2024
1.0.0-alpha.48 34 6/28/2024
1.0.0-alpha.46 32 6/28/2024
1.0.0-alpha.43 32 6/28/2024
1.0.0-alpha.38 33 6/28/2024
1.0.0-alpha.35 30 6/27/2024