Skip to content

Commit 1d493d0

Browse files
committed
- Args processing polish
- F# 6 polish (implicit Nullable)
1 parent 2bbe428 commit 1d493d0

File tree

6 files changed

+20
-23
lines changed

6 files changed

+20
-23
lines changed

src/Propulsion.Cosmos/ChangeFeedProcessor.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ type ChangeFeedProcessor =
132132
// NB for lag reporting to work correctly, it is of course still important that the writing take place, and that it be written via the CFP lib
133133
feedProcessorOptions.CheckpointFrequency.ExplicitCheckpoint <- true
134134
// Max Items is not emphasized as a control mechanism as it can only be used meaningfully when events are highly regular in size
135-
maxDocuments |> Option.iter (fun mi -> feedProcessorOptions.MaxItemCount <- Nullable mi)
135+
maxDocuments |> Option.iter (fun mi -> feedProcessorOptions.MaxItemCount <- mi)
136136
let mkD cid (dc : DocumentClient) =
137137
DocumentCollectionInfo(Uri=dc.ServiceEndpoint,ConnectionPolicy=dc.ConnectionPolicy,DatabaseName=cid.database,CollectionName=cid.container)
138138
ChangeFeedProcessorBuilder()

src/Propulsion.CosmosStore/ChangeFeedProcessor.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ type ChangeFeedProcessor =
138138
.GetChangeFeedProcessorBuilderWithManualCheckpoint(processorName_, Container.ChangeFeedHandlerWithManualCheckpoint handler)
139139
.WithLeaseContainer(leases)
140140
.WithPollInterval(feedPollDelay)
141-
.WithLeaseConfiguration(acquireInterval = Nullable leaseAcquireInterval, expirationInterval = Nullable leaseTtl, renewInterval = Nullable leaseRenewInterval)
141+
.WithLeaseConfiguration(acquireInterval = leaseAcquireInterval, expirationInterval = leaseTtl, renewInterval = leaseRenewInterval)
142142
.WithInstanceName(leaseOwnerId)
143143
.WithLeaseAcquireNotification(Container.ChangeFeedMonitorLeaseAcquireDelegate acquireAsync)
144144
.WithLeaseReleaseNotification(Container.ChangeFeedMonitorLeaseReleaseDelegate releaseAsync)

src/Propulsion.DynamoStore.Lambda/Propulsion.DynamoStore.Lambda.fsproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>net6.0</TargetFramework>
4+
<DisableImplicitFSharpCoreReference>false</DisableImplicitFSharpCoreReference>
45

56
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
67
<AWSProjectType>Lambda</AWSProjectType>
@@ -21,8 +22,6 @@
2122
<ItemGroup>
2223
<PackageReference Include="MinVer" Version="4.0.0" PrivateAssets="All" />
2324

24-
<PackageReference Include="FSharp.Core" Version="4.7.2" />
25-
2625
<PackageReference Include="Amazon.Lambda.Core" Version="2.1.0" />
2726
<PackageReference Include="Amazon.Lambda.DynamoDBEvents" Version="2.1.0" />
2827
<PackageReference Include="Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.0" />

src/Propulsion.DynamoStore/DynamoStoreIndexer.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ type DynamoStoreIndexer(log : Serilog.ILogger, context, cache, epochBytesCutoff,
2727
/// NOTE regardless of concurrency within a process, it's critical to avoid having >1 writer hitting the same trancheId as this will result on continual conflicts
2828
member _.IngestWithoutConcurrency(trancheId, spans) = async {
2929
let ingester = ingester trancheId
30-
let! originTranche = ingester.ActiveIngestionEpochId()
31-
return! ingester.IngestMany(originTranche, spans) |> Async.Ignore }
30+
let! originEpoch = ingester.ActiveIngestionEpochId()
31+
return! ingester.IngestMany(originEpoch, spans) |> Async.Ignore }

src/Propulsion.DynamoStore/DynamoStoreSource.fs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,14 @@ module private Impl =
117117
let events = Array.sub items (span.i - items[0].Index |> int) span.c.Length
118118
for e in events do ({ stream = IndexStreamId.toStreamName span.p; event = e } : StreamEvent) |] }
119119
let mutable prevLoaded, batchIndex = 0L, 0
120-
let report i len =
120+
let report (i : int option) len =
121121
if largeEnough && hydrating then
122-
let i = Option.toNullable i
123122
match cache.Count with
124123
| loadedNow when prevLoaded <> loadedNow ->
125124
prevLoaded <- loadedNow
126125
let eventsLoaded = cache.Values |> Seq.sumBy Array.length
127126
log.Information("DynamoStoreSource {sourceId}/{trancheId}/{epochId}@{offset}/{totalChanges} {result} {batch} {events}e Loaded {loadedS}/{loadingS}s {loadedE}/{loadingE}e",
128-
sourceId, string tid, string epochId, i, version, "Hydrated", batchIndex, len, cache.Count, streamEvents.Count, eventsLoaded, chosenEvents)
127+
sourceId, string tid, string epochId, Option.toNullable i, version, "Hydrated", batchIndex, len, cache.Count, streamEvents.Count, eventsLoaded, chosenEvents)
129128
| _ -> ()
130129
batchIndex <- batchIndex + 1
131130
for i, spans in state.changes do

tools/Propulsion.Tool/Program.fs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ open Propulsion.Tool.Args
66
open Serilog
77
open System
88

9+
module CosmosInit = Equinox.CosmosStore.Core.Initialization
10+
911
[<NoEquality; NoComparison>]
1012
type Parameters =
1113
| [<AltCommandLine("-V")>] Verbose
@@ -36,18 +38,17 @@ and [<NoComparison; NoEquality>] InitAuxParameters =
3638
| Mode _ -> "Configure RU mode to use Container-level RU, Database-level RU, or Serverless allocations (Default: Use Container-level allocation)."
3739
| Suffix _ -> "Specify Container Name suffix (default: `-aux`)."
3840
| Cosmos _ -> "Cosmos Connection parameters."
39-
40-
and CosmosInitInfo(p : ParseResults<InitAuxParameters>) =
41-
let throughputSpec =
42-
if p.Contains Autoscale then Equinox.CosmosStore.Core.Initialization.Throughput.Autoscale (p.GetResult(Rus, 4000))
43-
else Equinox.CosmosStore.Core.Initialization.Throughput.Manual (p.GetResult(Rus, 400))
41+
and CosmosModeType = Container | Db | Serverless
42+
and CosmosInitArguments(p : ParseResults<InitAuxParameters>) =
43+
let rusOrDefault value = p.GetResult(Rus, value)
44+
let throughput auto = if auto then CosmosInit.Throughput.Autoscale (rusOrDefault 4000) else CosmosInit.Throughput.Manual (rusOrDefault 400)
4445
member val ProvisioningMode =
45-
match p.GetResult(Mode, CosmosModeType.Container) with
46-
| CosmosModeType.Container -> Equinox.CosmosStore.Core.Initialization.Provisioning.Container throughputSpec
47-
| CosmosModeType.Db -> Equinox.CosmosStore.Core.Initialization.Provisioning.Database throughputSpec
48-
| CosmosModeType.Serverless ->
49-
if p.Contains Rus || p.Contains Autoscale then missingArg "Cannot specify RU/s or Autoscale in Serverless mode"
50-
Equinox.CosmosStore.Core.Initialization.Provisioning.Serverless
46+
match p.GetResult(Mode, CosmosModeType.Container), p.Contains Autoscale with
47+
| CosmosModeType.Container, auto -> CosmosInit.Provisioning.Container (throughput auto)
48+
| CosmosModeType.Db, auto -> CosmosInit.Provisioning.Database (throughput auto)
49+
| CosmosModeType.Serverless, auto when auto || p.Contains Rus -> missingArg "Cannot specify RU/s or Autoscale in Serverless mode"
50+
| CosmosModeType.Serverless, _ -> CosmosInit.Provisioning.Serverless
51+
5152
and [<NoEquality; NoComparison>] CheckpointParameters =
5253
| [<AltCommandLine "-s"; Mandatory>] Source of Propulsion.Feed.SourceId
5354
| [<AltCommandLine "-t"; Mandatory>] Tranche of Propulsion.Feed.TrancheId
@@ -99,7 +100,6 @@ and [<NoComparison; NoEquality>] StatsParameters =
99100
member a.Usage = a |> function
100101
| Cosmos _ -> "Specify CosmosDB parameters."
101102
| Dynamo _ -> "Specify DynamoDB parameters."
102-
and CosmosModeType = Container | Db | Serverless
103103

104104
let [<Literal>] appName = "propulsion-tool"
105105

@@ -108,8 +108,7 @@ module CosmosInit =
108108
let aux (c, p : ParseResults<InitAuxParameters>) =
109109
match p.GetSubCommand() with
110110
| InitAuxParameters.Cosmos sa ->
111-
let a = Args.Cosmos.Arguments(c, sa)
112-
let mode = (CosmosInitInfo p).ProvisioningMode
111+
let mode, a = (CosmosInitArguments p).ProvisioningMode, Args.Cosmos.Arguments(c, sa)
113112
let client = a.ConnectLeases()
114113
match mode with
115114
| Equinox.CosmosStore.Core.Initialization.Provisioning.Container throughput ->

0 commit comments

Comments
 (0)