Projects Issues Blogs Broadcasts Groups Events Resources
Project

apogee-net

Allows activity to be batched together in the background

Apogee.NET

Travis NuGet

Description

Apogee.NET allows activity to be batched together in the background.

Licensing

Released under the MIT License. See the LICENSE file for further details.

Installation

In the Package Manager Console execute

Install-Package Apogee

Or update *.csproj to include a dependency on

<ItemGroup>
  <PackageReference Include="Apogee" Version="0.1.0-*" />
</ItemGroup>

Usage

Use the AddApogee configuration method to define all batch processors. Follow up with the UseApogee method to ensure that the system is started when the application starts.

See the following example for tracking visitors to the web site. It takes any activity that occurs, and defers it to the background in a batch to prevent the activity from taking valuable time from the intent of the user.

public void ConfigureServices(IServiceCollection services) => 
  services.AddApogee(options => options.AddProcessorScoped<Visitor, VisitorProcessor>());
  
public void Configure(IApplicationBuilder app, IHostingEnvironment env) =>
  app.UseApogee().UseMvc();
  
class VisitorProcessor : IBatchProcessor<Visitor> {
  readonly VisitorContext _context;
  public VisitorProcessor(VisitorContext context) =>
    _context = context;

  public void Process(Batch<Visitor> batch) {
    _context.Visitors.AddRange(batch.Items);
    _context.SaveChanges();
  }
}

class VisitorMiddleware {
  readonly RequestDelegate _next;
  readonly IBatchService<Visitor> _batchService;
  public VisitorMiddleware(RequestDelegate next, IBatchService<Visitor> batchService) {
    _next = next;
    _batchService = batchService;
  }
  
  public Task InvokeAsync(HttpContext context) {
    var visitor = new Visitor(context);
    _batchService.Add(visitor);
    return _next(context);
  }
}

For additional usage see Tests.

NuGet

Apogee (fuget.org)
232 Total Downloads <1 Downloads Per Day Latest Version: 232 (December 6, 2017) Hide All Versions Show All Versions
Version Downloads Last Updated
12/6/2017 December 6, 2017
1
0
0
Source

{{ 'https://github.com/joncloud/apogee-net' | no-protocol }}

NuGet