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 efa0834
Showing 1 changed file with 4 additions and 3 deletions.
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 efa0834

Please sign in to comment.