项目作者: Informatievlaanderen

项目描述 :
Generic projection runner infrastructure.
高级语言: C#
项目地址: git://github.com/Informatievlaanderen/projector.git
创建时间: 2019-02-26T15:51:01Z
项目社区:https://github.com/Informatievlaanderen/projector

开源协议:MIT License

下载


Be.Vlaanderen.Basisregisters.Projector Build Status

Generic projection runner infrastructure.

Usage

Example types

  1. class ProjectionContext : Be.Vlaanderen.Basisregisters.ProjectionHandling.Runner.RunnerDbContext<ProjectionContext> { ... }
  2. class Projections : Be.Vlaanderen.Basisregisters.ProjectionHandling.Connector.ConnectedProjection<ProjectionContext> { ... }

Creating migration helpers

  1. class ProjectionContextMigrationHelper : RunnerDbContextMigrationHelper<ProjectionContext> {
  2. public ProjectionContextMigrationHelper(
  3. string connectionString,
  4. ILoggerFactory loggerFactory)
  5. : base(
  6. connectionString,
  7. new HistoryConfiguration
  8. {
  9. Schema = "MigrationsSchema",
  10. Table = "MigrationTablesHistoryTable"
  11. },
  12. loggerFactory)
  13. { }
  14. protected override ProjectionContext CreateContext(DbContextOptions<ExtractContext> migrationContextOptions)
  15. {
  16. return new ProjectionContext(migrationContextOptions);
  17. }
  18. }

Registering components with Autofac

  1. Autofac.ContainerBuilder builder;
  2. // Register Projector module
  3. builder.RegisterModule<ProjectorModule>();
  4. // Register migration helpers for a ProjectionContext
  5. builder
  6. .RegisterProjectionMigrator<ProjectionContextMigrationFactory>(configuration, loggerFactory);
  7. // Register ConnectedProjections for a projection context
  8. builder
  9. .RegisterProjections<Projections, ProjectionContext>();
  10. // Register ConnectedProjections that require initialisation parameters
  11. builder
  12. .RegisterProjections<Projections, ProjectionContext>(
  13. () => new Projections(parameter1, parameter2, ...)
  14. );
  15. // Register ConnectedProjections that require initialisation parameters and/or automically resolved dependencies
  16. builder
  17. .RegisterProjections<Projections, ProjectionContext>(
  18. container => new Projections(parameter1, container.Resolve<TDependency>(), ...)
  19. );

Managing the registered projections from code

  1. IConnectedProjectionsManager projectionManager;
  2. // Status of registered projections
  3. var projectsStatus = projectionManager.GetRegisteredProjections();
  4. // Start all registered projections
  5. projectionManager.Start();
  6. // Start a specific projection by id
  7. projectionManager.Start(projection);
  8. // Stop all registered projections
  9. projectionManager.Stop();
  10. // Stop a specific projection by id
  11. projectionManager.Stop(projection);

Managing the registered projections with api calls

Inherit Controller from DefaultProjectionContoller

  1. [ApiRoute("controller-path")]
  2. public class ProjectionsController : DefaultProjectorController
  3. {
  4. public ProjectionsController(IConnectedProjectionsManager connectedProjectionsManager)
  5. : base(connectedProjectionsManager)
  6. { }
  7. }

Status of registered projections: [GET] https://projector.url/controller-path/
Start all registered projections: [POST] https://projector.url/controller-path/start/all
Start a specific projection by id: [POST] https://projector.url/controller-path/start/{projection}
Stop all registered projections: [POST] https://projector.url/controller-path/stop/all
Stop a specific projection by id: [POST] https://projector.url/controller-path/stop/{projection}

Quick contributing guide

  • Fork and clone locally.
  • Build the solution with Visual Studio, build.cmd or build.sh.
  • Create a topic specific branch in git. Add a nice feature in the code. Do not forget to add tests and/or docs.
  • Run build.cmd or build.sh to make sure everything still compiles and all tests are still passing.
  • When built, you’ll find the binaries in ./dist which you can then test with locally, to ensure the bug or feature has been successfully implemented.
  • Send a Pull Request.

Development

Getting started

TODO: More to come :)

Possible build targets

Our build.sh script knows a few tricks. By default it runs with the Test target.

The buildserver passes in BITBUCKET_BUILD_NUMBER as an integer to version the results and BUILD_DOCKER_REGISTRY to point to a Docker registry to push the resulting Docker images.

NpmInstall

Run an npm install to setup Commitizen and Semantic Release.

DotNetCli

Checks if the requested .NET Core SDK and runtime version defined in global.json are available.
We are pedantic about these being the exact versions to have identical builds everywhere.

Clean

Make sure we have a clean build directory to start with.

Restore

Restore dependencies for debian.8-x64 and win10-x64 using dotnet restore and Paket.

Build

Builds the solution in Release mode with the .NET Core SDK and runtime specified in global.json
It builds it platform-neutral, debian.8-x64 and win10-x64 version.

Test

Runs dotnet test against the test projects.

Publish

Runs a dotnet publish for the debian.8-x64 and win10-x64 version as a self-contained application.
It does this using the Release configuration.

Pack

Packs the solution using Paket in Release mode and places the result in the dist folder.
This is usually used to build documentation NuGet packages.

Credits

Languages & Frameworks

Libraries

  • xUnit - xUnit.net is a free, open source, community-focused unit testing tool for the .NET Framework. - Apache License 2.0
  • Autofac - An addictive .NET IoC container. - MIT
  • AutoFixture - AutoFixture is an open source library for .NET designed to minimize the ‘Arrange’ phase of your unit tests in order to maximize maintainability. - MIT
  • FluentAssertions - Fluent API for asserting the results of unit tests. - Apache License 2.0

Tooling

Flemish Government Frameworks

Flemish Government Libraries