Skip to content

Commit

Permalink
Add AllProjector
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Feb 7, 2020
1 parent afc68d6 commit e9c7d92
Show file tree
Hide file tree
Showing 6 changed files with 441 additions and 1 deletion.
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"sdk": {
"version": "2.1.504"
"version": "2.1.500"
}
}
29 changes: 29 additions & 0 deletions propulsion-all-projector/.template.config/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"$schema": "http://json.schemastore.org/template",
"author": "@jet @bartelink",
"classifications": [
"Event Sourcing",
"Equinox",
"Propulsion",
"EventStore",
"Kafka"
],
"tags": {
"language": "F#"
},
"identity": "Propulsion.Template.AllProjector",
"name": "Propulsion EventStore $all Projector",
"shortName": "proAllProjector",
"sourceName": "ProjectorTemplate",
"preferNameDirectory": true,

"symbols": {
"kafka": {
"type": "parameter",
"datatype": "bool",
"isRequired": false,
"defaultValue": "false",
"description": "Include code projecting to Kafka."
}
}
}
24 changes: 24 additions & 0 deletions propulsion-all-projector/AllProjector.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<WarningLevel>5</WarningLevel>
</PropertyGroup>

<ItemGroup>
<None Include="README.md" />
<Compile Include="Handler.fs" />
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Argu" Version="5.4.0" />
<PackageReference Include="Destructurama.FSharp" Version="1.1.1-dev-00033" />
<PackageReference Include="Equinox.Cosmos" Version="2.0.0-rc9" />
<PackageReference Include="Propulsion.EventStore" Version="2.0.0-rc2" />
<PackageReference Include="Propulsion.Kafka" Version="2.0.0-rc2" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions propulsion-all-projector/Handler.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module ProjectorTemplate.Handler

open Propulsion.EventStore

/// Responsible for inspecting and then either dropping or tweaking events coming from EventStore
// NB the `index` needs to be contiguous with existing events - IOW filtering needs to be at stream (and not event) level
let tryMapEvent filterByStreamName (x : EventStore.ClientAPI.ResolvedEvent) =
match x.Event with
| e when not e.IsJson || e.EventStreamId.StartsWith "$" || not (filterByStreamName e.EventStreamId) -> None
| PropulsionStreamEvent e -> Some e

/// Responsible for wrapping a span of events for a specific stream into an envelope (we use the well-known Propulsion.Codec form)
/// Most manipulation should take place before events enter the scheduler
let render (stream: FsCodec.StreamName, span: Propulsion.Streams.StreamSpan<_>) = async {
let value =
span
|> Propulsion.Codec.NewtonsoftJson.RenderedSpan.ofStreamSpan stream
|> Propulsion.Codec.NewtonsoftJson.Serdes.Serialize
return FsCodec.StreamName.toString stream, value }

0 comments on commit e9c7d92

Please sign in to comment.