Skip to content

Commit 2fc93de

Browse files
committed
feat(StreamFilter,CreateStreamFilter): Add includeSystem option
1 parent 79a0d06 commit 2fc93de

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/Propulsion/Propulsion.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<PropertyGroup>
66
<TargetFramework>net6.0</TargetFramework>
7-
<PackageValidationBaselineVersion>3.0.0-rc.12</PackageValidationBaselineVersion>
7+
<!-- <PackageValidationBaselineVersion>3.0.0-rc.12</PackageValidationBaselineVersion>-->
88
</PropertyGroup>
99

1010
<ItemGroup>

src/Propulsion/StreamFilter.fs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
namespace Propulsion
22

3-
open System.Runtime.InteropServices
43
open Propulsion.Internal
4+
open System.Runtime.InteropServices
55

66
type StreamFilter([<Optional>] allowCats, [<Optional>] denyCats, [<Optional>] allowSns, [<Optional>] denySns,
77
[<Optional>] allowEts, [<Optional>] denyEts,
8-
[<Optional; DefaultParameterValue(false)>] ?incIndexes,
8+
[<Optional; DefaultParameterValue(false)>] ?includeSystem,
99
[<Optional; DefaultParameterValue(null)>] ?log) =
1010
let log = lazy defaultArg log Serilog.Log.Logger
1111
let defA x = match x with null -> Array.empty | xs -> Seq.toArray xs
1212

13-
let allowCats, denyCats, incIndexes = defA allowCats, defA denyCats, defaultArg incIndexes false
13+
let allowCats, denyCats, includeSystem_ = defA allowCats, defA denyCats, defaultArg includeSystem false
1414
let allowSns, denySns = defA allowSns, defA denySns
1515
let allowEts, denyEts = defA allowEts, defA denyEts
1616
let isPlain = Seq.forall (fun x -> System.Char.IsLetterOrDigit x || x = '_')
@@ -27,19 +27,20 @@ type StreamFilter([<Optional>] allowCats, [<Optional>] denyCats, [<Optional>] al
2727
let validStream = filter FsCodec.StreamName.toString (allowSns, denySns)
2828
let isTransactionalStream (sn: FsCodec.StreamName) = let sn = FsCodec.StreamName.toString sn in not (sn.StartsWith('$'))
2929

30-
member _.CreateStreamFilter([<Optional>] maybeCategories) =
30+
member _.CreateStreamFilter([<Optional>] maybeCategories, [<Optional>] ?includeSystem) =
31+
let includeSystem = includeSystem_ || defaultArg includeSystem false
3132
let handlerCats = defA maybeCategories
3233
let allowCats = Array.append handlerCats allowCats
3334
let validCat = filter FsCodec.StreamName.Category.ofStreamName (allowCats, denyCats)
3435
let allowCats = match allowCats with [||] -> [| ".*" |] | xs -> xs
35-
let denyCats = if incIndexes then denyCats else Array.append denyCats [| "^\$" |]
36+
let denyCats = if includeSystem_ then denyCats else Array.append denyCats [| "^\$" |]
3637
let allowSns, denySns = match allowSns, denySns with [||], [||] -> [|".*"|], [||] | x -> x
3738
let allowEts, denyEts = match allowEts, denyEts with [||], [||] -> [|".*"|], [||] | x -> x
3839
log.Value.Information("Categories ☑️ {@allowCats} 🚫{@denyCats} Streams ☑️ {@allowStreams} 🚫{denyStreams} Events ☑️ {allowEts} 🚫{@denyEts}",
3940
asRe allowCats, asRe denyCats, asRe allowSns, asRe denySns, asRe allowEts, asRe denyEts)
4041
fun sn ->
4142
validCat sn
4243
&& validStream sn
43-
&& (incIndexes || isTransactionalStream sn)
44+
&& (includeSystem || isTransactionalStream sn)
4445

4546
member val EventFilter = filter (fun (x: Propulsion.Sinks.Event) -> x.EventType) (allowEts, denyEts)

0 commit comments

Comments
 (0)