Passby.Microservice.Template 1.0.6

There is a newer version of this package available.
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                
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="Passby.Microservice.Template" Version="1.0.6" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Passby.Microservice.Template --version 1.0.6                
#r "nuget: Passby.Microservice.Template, 1.0.6"                
#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 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

  1. Swagger
services.AddSwaggerSupport();
app.UseSwaggerSupport();
  1. Health Check with /ready path
services.AddHealthCheckSupport();
app.UseHealthCheckSupport();
  1. XRay Tracing
services.AddXRayHttpTracingSupport();
app.UseXrayTracingSupport(env);
  1. Amazon Services
services.AddAwsServicesSupport();

###CommandBus and EventBus To enable AWS Command and AWS Event bus use the following:

  1. In Startup.cs
services.AddAwsEventBus();
services.AddAwsCommandBus();
services.AddAwsConfiguration(Configuration);
  1. In appsettings.json
"EventsConfiguration": {
     "Events": [
       {
         "EventName": "EventReceived",
         "TopicArn": "arn:aws:sns:region:accountnumber:EventReceived",
         "QueueArn": "https://region.amazonaws.com/accountnumber/EventReceived"
       }
     ]
  1. 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
            });
  1. 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

There are no supported framework assets in this package.

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.

Version Downloads Last updated
1.0.12 2,697 3/15/2019
1.0.11 654 2/27/2019
1.0.10 645 2/22/2019
1.0.9 736 1/28/2019
1.0.8 741 1/22/2019
1.0.6 737 1/22/2019
1.0.5 773 1/21/2019
1.0.4 772 1/18/2019
1.0.3 774 1/16/2019