Passby.Microservice.Template
1.0.6
See the version list below for details.
dotnet add package Passby.Microservice.Template --version 1.0.6
NuGet\Install-Package Passby.Microservice.Template -Version 1.0.6
<PackageReference Include="Passby.Microservice.Template" Version="1.0.6" />
paket add Passby.Microservice.Template --version 1.0.6
#r "nuget: Passby.Microservice.Template, 1.0.6"
// Install Passby.Microservice.Template as a Cake Addin #addin nuget:?package=Passby.Microservice.Template&version=1.0.6 // Install Passby.Microservice.Template as a Cake Tool #tool nuget:?package=Passby.Microservice.Template&version=1.0.6
#Usage of the template
###Enable Some Features
- Swagger
services.AddSwaggerSupport();
app.UseSwaggerSupport();
- Health Check with /ready path
services.AddHealthCheckSupport();
app.UseHealthCheckSupport();
- XRay Tracing
services.AddXRayHttpTracingSupport();
app.UseXrayTracingSupport(env);
- Amazon Services
services.AddAwsServicesSupport();
###CommandBus and EventBus To enable AWS Command and AWS Event bus use the following:
- In Startup.cs
services.AddAwsEventBus();
services.AddAwsCommandBus();
services.AddAwsConfiguration(Configuration);
- In appsettings.json
"EventsConfiguration": {
"Events": [
{
"EventName": "EventReceived",
"TopicArn": "arn:aws:sns:region:accountnumber:EventReceived",
"QueueArn": "https://region.amazonaws.com/accountnumber/EventReceived"
}
]
- Send command, Use the following dependency in the controller to be injected, the publish command will return an object with status and exception if any:
private readonly ICommandBus _commandBus;
PublishEventResponse response=await _commandBus.Publish(new EventReceived
{
Rank = id
});
- Handle Event
Declare your event and the handler:
public class EventReceived:IntegrationEvent
{
public int Rank { get; set; }
}
public class EventReceivedHandler : IIntegrationEventHandler<EventReceived>
{
private readonly ILogger<EventReceivedHandler> _logger;
public EventReceivedHandler(ILogger<EventReceivedHandler> logger)
{
_logger = logger;
}
public Task Handle(EventReceived @event)
{
_logger.LogInformation($"Message Received with --> {@event.Rank}");
return Task.CompletedTask;
}
}
Register the Event and Handler in Startup with some helper methods:
public void ConfigureServices(IServiceCollection services)
{
services.AddEventHandler<EventReceived,EventReceivedHandler>();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseEventSubscription<EventReceived, EventReceivedHandler>();
}
###Enable XRay with HttpClient To register the Service2Provider with Injected HttpClient that supports XRay TRacing, in Startup.cs
services.AddHttpClient<IService2Provider, Service2Provider>(client =>
{
client.BaseAddress = new Uri("http://service2.internal");
}).AddHttpMessageHandler<HttpClientXRayTracingHandler>();
###Base Api Controller
###Domain Driven Design
####Aggregate Root
####Wrappers
Event Sourcing
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.