Skip to content

Commit

Permalink
Generic filter
Browse files Browse the repository at this point in the history
  • Loading branch information
bartelink committed Sep 6, 2024
1 parent 42ab64e commit 464bfba
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Propulsion/Propulsion.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFramework>net6.0</TargetFramework>
<!-- NOTE FSharp.Core dep is implies by what `FSharp.Control.TaskSeq` dictates; see below -->
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<PackageValidationBaselineVersion>3.0.0-rc.14.3</PackageValidationBaselineVersion>
<!-- <PackageValidationBaselineVersion>3.0.0-rc.14.3</PackageValidationBaselineVersion>-->
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 4 additions & 3 deletions src/Propulsion/StreamFilter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ namespace Propulsion
open Propulsion.Internal
open System.Runtime.InteropServices

type StreamFilter([<Optional>] allowCats, [<Optional>] denyCats, [<Optional>] allowSns, [<Optional>] denySns,
type StreamFilter<'EventBody>(
[<Optional>] allowCats, [<Optional>] denyCats, [<Optional>] allowSns, [<Optional>] denySns,
[<Optional>] allowEts, [<Optional>] denyEts,
[<Optional; DefaultParameterValue(false)>] ?includeSystem,
[<Optional; DefaultParameterValue(null)>] ?log) =
Expand Down Expand Up @@ -36,11 +37,11 @@ type StreamFilter([<Optional>] allowCats, [<Optional>] denyCats, [<Optional>] al
let denyCats = if includeSystem_ then denyCats else Array.append denyCats [| "^\$" |]
let allowSns, denySns = match allowSns, denySns with [||], [||] -> [|".*"|], [||] | x -> x
let allowEts, denyEts = match allowEts, denyEts with [||], [||] -> [|".*"|], [||] | x -> x
log.Value.Information("Categories ☑️ {@allowCats} 🚫{@denyCats} Streams ☑️ {@allowStreams} 🚫{denyStreams} Events ☑️ {allowEts} 🚫{@denyEts}",
log.Value.Information("Categories {@allowCats} 🚫{@denyCats} Streams {@allowStreams} 🚫{denyStreams} Events {allowEts} 🚫{@denyEts}",
asRe allowCats, asRe denyCats, asRe allowSns, asRe denySns, asRe allowEts, asRe denyEts)
fun sn ->
validCat sn
&& validStream sn
&& (includeSystem || isTransactionalStream sn)

member val EventFilter = filter (fun (x: Propulsion.Sinks.Event) -> x.EventType) (allowEts, denyEts)
member val EventFilter = filter (fun (x: FsCodec.ITimelineEvent<'EventBody>) -> x.EventType) (allowEts, denyEts)

0 comments on commit 464bfba

Please sign in to comment.