From 1d9f55dada51783b47111d4ed40c06c2e6880988 Mon Sep 17 00:00:00 2001 From: Ruben Bartelink Date: Sun, 23 Feb 2020 21:56:50 +0000 Subject: [PATCH] AllProjector --noEventStore cleanup --- README.md | 4 ++-- .../.template.config/template.json | 6 ++++++ propulsion-all-projector/AllProjector.fsproj | 2 ++ propulsion-all-projector/Handler.fs | 2 +- propulsion-all-projector/Program.fs | 11 ++++++++++- propulsion-all-projector/README.md | 6 +++--- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0dde4d31c..5b69d94b4 100644 --- a/README.md +++ b/README.md @@ -32,8 +32,8 @@ This repo hosts the source for Jet's [`dotnet new`](https://docs.microsoft.com/e Standard processing shows importing (in summary form) from an aggregate in `EventStore` or `Cosmos` to a Summary form in `Cosmos` (use `-b`(`lank`) to remove, yielding a minimal projector) - `-k` adds Optional projection to Apache Kafka using [`Propulsion.Kafka`](https://github.com/jet/propulsion) (instead of ingesting into a local `Cosmos` store). - `-noEventStore` removes support for projecting from EventStore from the emitted code + `--kafka` adds Optional projection to Apache Kafka using [`Propulsion.Kafka`](https://github.com/jet/propulsion) (instead of ingesting into a local `Cosmos` store). + `--noEventStore` removes support for projecting from EventStore from the emitted code - [`proSync`](propulsion-sync/README.md) - Boilerplate for a console app that that syncs events between [`Equinox.Cosmos` and `Equinox.EventStore` stores](https://github.com/jet/equinox) using the [relevant `Propulsion`.* libraries](https://github.com/jet/propulsion), filtering/enriching/mapping Events as necessary. diff --git a/propulsion-all-projector/.template.config/template.json b/propulsion-all-projector/.template.config/template.json index 6a43616b1..75294102a 100644 --- a/propulsion-all-projector/.template.config/template.json +++ b/propulsion-all-projector/.template.config/template.json @@ -57,6 +57,12 @@ "exclude": [ "Ingester.fs" ] + }, + { + "condition": "noEventStore && !kafka", + "exclude": [ + "Handler.fs" + ] } ] } diff --git a/propulsion-all-projector/AllProjector.fsproj b/propulsion-all-projector/AllProjector.fsproj index 560fcb8e2..8fdae7e5c 100644 --- a/propulsion-all-projector/AllProjector.fsproj +++ b/propulsion-all-projector/AllProjector.fsproj @@ -17,7 +17,9 @@ + + diff --git a/propulsion-all-projector/Handler.fs b/propulsion-all-projector/Handler.fs index 3869e03bb..43562b73f 100644 --- a/propulsion-all-projector/Handler.fs +++ b/propulsion-all-projector/Handler.fs @@ -1,6 +1,6 @@ module AllTemplate.Handler - //#if (!noEventStore) + open Propulsion.EventStore /// Responsible for inspecting and then either dropping or tweaking events coming from EventStore diff --git a/propulsion-all-projector/Program.fs b/propulsion-all-projector/Program.fs index 2018bbb45..7015b6b87 100644 --- a/propulsion-all-projector/Program.fs +++ b/propulsion-all-projector/Program.fs @@ -368,7 +368,16 @@ module Logging = .Destructure.FSharpTypes() .Enrich.FromLogContext() |> fun c -> if verbose then c.MinimumLevel.Debug() else c - |> fun c -> let t = "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj} {NewLine}{Exception}" + // LibLog writes to the global logger, so we need to control the emission + |> fun c -> let cfpl = if changeLogVerbose then Serilog.Events.LogEventLevel.Debug else Serilog.Events.LogEventLevel.Warning + c.MinimumLevel.Override("Microsoft.Azure.Documents.ChangeFeedProcessor", cfpl) + |> fun c -> let isCfp429a = Filters.Matching.FromSource("Microsoft.Azure.Documents.ChangeFeedProcessor.LeaseManagement.DocumentServiceLeaseUpdater").Invoke + let isCfp429b = Filters.Matching.FromSource("Microsoft.Azure.Documents.ChangeFeedProcessor.PartitionManagement.LeaseRenewer").Invoke + let isCfp429c = Filters.Matching.FromSource("Microsoft.Azure.Documents.ChangeFeedProcessor.PartitionManagement.PartitionLoadBalancer").Invoke + let isCfp429d = Filters.Matching.FromSource("Microsoft.Azure.Documents.ChangeFeedProcessor.FeedProcessing.PartitionProcessor").Invoke + let isCfp x = isCfp429a x || isCfp429b x || isCfp429c x || isCfp429d x + if changeLogVerbose then c else c.Filter.ByExcluding(fun x -> isCfp x) + |> fun c -> let t = "[{Timestamp:HH:mm:ss} {Level:u3}] {partitionKeyRangeId,2} {Message:lj} {NewLine}{Exception}" c.WriteTo.Console(theme=Sinks.SystemConsole.Themes.AnsiConsoleTheme.Code, outputTemplate=t) |> fun c -> c.CreateLogger() diff --git a/propulsion-all-projector/README.md b/propulsion-all-projector/README.md index 5cdb02201..a4edd3907 100644 --- a/propulsion-all-projector/README.md +++ b/propulsion-all-projector/README.md @@ -17,12 +17,12 @@ This project was generated using: //#if kafka dotnet new -i Equinox.Templates # just once, to install/update in the local templates store - dotnet new proAllProjector -noEventStore -k # -k => include Kafka projection logic + dotnet new proAllProjector --noEventStore -k # -k => include Kafka projection logic //#else dotnet new -i Equinox.Templates # just once, to install/update in the local templates store # add -k to add Kafka Projection logic - dotnet new proAllProjector -noEventStore # use --help to see options + dotnet new proAllProjector --noEventStore # use --help to see options //#endif //#else //#if kafka @@ -63,8 +63,8 @@ This project was generated using: NOTE when projecting from EventStore, the current implementation stores the checkpoints within the CosmosDB store in order to remove feedback effects. (Yes, someone should do a PR to store the checkpoints in EventStore itself; this is extracted from working code, which can assume there's always a CosmosDB around) -//#endif +//#endif 3. To run an instance of the Projector from a CosmosDb ChangeFeed //#if kafka