envio 3.0.0-alpha.21 → 3.0.0-alpha.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin.mjs +2 -48
- package/evm.schema.json +67 -0
- package/fuel.schema.json +67 -0
- package/index.d.ts +822 -38
- package/index.js +5 -3
- package/package.json +10 -8
- package/rescript.json +5 -9
- package/src/Address.res +4 -5
- package/src/Address.res.mjs +9 -12
- package/src/Api.res +15 -0
- package/src/Api.res.mjs +20 -0
- package/src/Batch.res +32 -34
- package/src/Batch.res.mjs +172 -187
- package/src/Bin.res +89 -0
- package/src/Bin.res.mjs +97 -0
- package/src/ChainFetcher.res +33 -57
- package/src/ChainFetcher.res.mjs +197 -227
- package/src/ChainManager.res +6 -14
- package/src/ChainManager.res.mjs +74 -85
- package/src/ChainMap.res +14 -16
- package/src/ChainMap.res.mjs +38 -38
- package/src/Config.res +193 -135
- package/src/Config.res.mjs +566 -592
- package/src/Core.res +182 -0
- package/src/Core.res.mjs +207 -0
- package/src/Ecosystem.res +25 -4
- package/src/Ecosystem.res.mjs +12 -13
- package/src/Env.res +20 -13
- package/src/Env.res.mjs +124 -113
- package/src/EnvSafe.res +269 -0
- package/src/EnvSafe.res.mjs +296 -0
- package/src/EnvSafe.resi +18 -0
- package/src/Envio.res +37 -26
- package/src/Envio.res.mjs +59 -60
- package/src/ErrorHandling.res +2 -2
- package/src/ErrorHandling.res.mjs +15 -15
- package/src/EventConfigBuilder.res +219 -81
- package/src/EventConfigBuilder.res.mjs +259 -202
- package/src/EventProcessing.res +27 -38
- package/src/EventProcessing.res.mjs +165 -183
- package/src/EventUtils.res +11 -11
- package/src/EventUtils.res.mjs +21 -22
- package/src/EvmTypes.res +0 -1
- package/src/EvmTypes.res.mjs +5 -5
- package/src/FetchState.res +360 -256
- package/src/FetchState.res.mjs +958 -914
- package/src/GlobalState.res +365 -351
- package/src/GlobalState.res.mjs +958 -992
- package/src/GlobalStateManager.res +1 -2
- package/src/GlobalStateManager.res.mjs +36 -44
- package/src/HandlerLoader.res +107 -23
- package/src/HandlerLoader.res.mjs +128 -38
- package/src/HandlerRegister.res +127 -103
- package/src/HandlerRegister.res.mjs +164 -164
- package/src/HandlerRegister.resi +12 -4
- package/src/Hasura.res +35 -22
- package/src/Hasura.res.mjs +158 -167
- package/src/InMemoryStore.res +20 -27
- package/src/InMemoryStore.res.mjs +64 -80
- package/src/InMemoryTable.res +34 -39
- package/src/InMemoryTable.res.mjs +165 -170
- package/src/Internal.res +52 -33
- package/src/Internal.res.mjs +84 -81
- package/src/LazyLoader.res.mjs +55 -61
- package/src/LoadLayer.res +77 -78
- package/src/LoadLayer.res.mjs +160 -189
- package/src/LoadManager.res +16 -21
- package/src/LoadManager.res.mjs +79 -84
- package/src/LogSelection.res +236 -68
- package/src/LogSelection.res.mjs +211 -141
- package/src/Logging.res +13 -9
- package/src/Logging.res.mjs +130 -143
- package/src/Main.res +428 -51
- package/src/Main.res.mjs +528 -271
- package/src/Persistence.res +77 -84
- package/src/Persistence.res.mjs +131 -132
- package/src/PgStorage.res +291 -167
- package/src/PgStorage.res.mjs +797 -817
- package/src/Prometheus.res +50 -58
- package/src/Prometheus.res.mjs +345 -373
- package/src/ReorgDetection.res +22 -24
- package/src/ReorgDetection.res.mjs +100 -106
- package/src/SafeCheckpointTracking.res +7 -7
- package/src/SafeCheckpointTracking.res.mjs +40 -43
- package/src/SimulateItems.res +41 -49
- package/src/SimulateItems.res.mjs +257 -272
- package/src/Sink.res +2 -2
- package/src/Sink.res.mjs +22 -26
- package/src/TableIndices.res +1 -2
- package/src/TableIndices.res.mjs +42 -48
- package/src/TestIndexer.res +196 -189
- package/src/TestIndexer.res.mjs +536 -536
- package/src/TestIndexerProxyStorage.res +15 -16
- package/src/TestIndexerProxyStorage.res.mjs +98 -122
- package/src/TestIndexerWorker.res +4 -0
- package/src/TestIndexerWorker.res.mjs +7 -0
- package/src/Throttler.res +3 -3
- package/src/Throttler.res.mjs +23 -24
- package/src/Time.res +1 -1
- package/src/Time.res.mjs +18 -21
- package/src/TopicFilter.res +3 -3
- package/src/TopicFilter.res.mjs +29 -30
- package/src/UserContext.res +93 -54
- package/src/UserContext.res.mjs +197 -182
- package/src/Utils.res +141 -86
- package/src/Utils.res.mjs +334 -295
- package/src/bindings/BigDecimal.res +0 -2
- package/src/bindings/BigDecimal.res.mjs +19 -23
- package/src/bindings/ClickHouse.res +28 -27
- package/src/bindings/ClickHouse.res.mjs +243 -240
- package/src/bindings/DateFns.res +11 -11
- package/src/bindings/DateFns.res.mjs +7 -7
- package/src/bindings/EventSource.res.mjs +2 -2
- package/src/bindings/Express.res +2 -5
- package/src/bindings/Hrtime.res +2 -2
- package/src/bindings/Hrtime.res.mjs +30 -32
- package/src/bindings/Lodash.res.mjs +1 -1
- package/src/bindings/NodeJs.res +14 -9
- package/src/bindings/NodeJs.res.mjs +20 -20
- package/src/bindings/Pino.res +8 -10
- package/src/bindings/Pino.res.mjs +40 -43
- package/src/bindings/Postgres.res +2 -5
- package/src/bindings/Postgres.res.mjs +9 -9
- package/src/bindings/PromClient.res +17 -2
- package/src/bindings/PromClient.res.mjs +30 -7
- package/src/bindings/SDSL.res.mjs +2 -2
- package/src/bindings/Viem.res +4 -4
- package/src/bindings/Viem.res.mjs +20 -22
- package/src/bindings/Vitest.res +1 -1
- package/src/bindings/Vitest.res.mjs +2 -2
- package/src/bindings/WebSocket.res +1 -1
- package/src/db/EntityHistory.res +9 -3
- package/src/db/EntityHistory.res.mjs +84 -59
- package/src/db/InternalTable.res +62 -60
- package/src/db/InternalTable.res.mjs +271 -203
- package/src/db/Schema.res +1 -2
- package/src/db/Schema.res.mjs +28 -32
- package/src/db/Table.res +28 -27
- package/src/db/Table.res.mjs +276 -292
- package/src/sources/EventRouter.res +21 -16
- package/src/sources/EventRouter.res.mjs +55 -57
- package/src/sources/Evm.res +17 -1
- package/src/sources/Evm.res.mjs +16 -8
- package/src/sources/EvmChain.res +15 -17
- package/src/sources/EvmChain.res.mjs +40 -42
- package/src/sources/Fuel.res +14 -1
- package/src/sources/Fuel.res.mjs +16 -8
- package/src/sources/FuelSDK.res +1 -1
- package/src/sources/FuelSDK.res.mjs +6 -8
- package/src/sources/HyperFuel.res +8 -10
- package/src/sources/HyperFuel.res.mjs +113 -123
- package/src/sources/HyperFuelClient.res.mjs +6 -7
- package/src/sources/HyperFuelSource.res +19 -20
- package/src/sources/HyperFuelSource.res.mjs +339 -356
- package/src/sources/HyperSync.res +11 -13
- package/src/sources/HyperSync.res.mjs +206 -220
- package/src/sources/HyperSyncClient.res +5 -7
- package/src/sources/HyperSyncClient.res.mjs +70 -75
- package/src/sources/HyperSyncHeightStream.res +8 -9
- package/src/sources/HyperSyncHeightStream.res.mjs +78 -86
- package/src/sources/HyperSyncJsonApi.res +18 -15
- package/src/sources/HyperSyncJsonApi.res.mjs +201 -231
- package/src/sources/HyperSyncSource.res +17 -21
- package/src/sources/HyperSyncSource.res.mjs +268 -290
- package/src/sources/Rpc.res +5 -5
- package/src/sources/Rpc.res.mjs +168 -192
- package/src/sources/RpcSource.res +166 -167
- package/src/sources/RpcSource.res.mjs +972 -1046
- package/src/sources/RpcWebSocketHeightStream.res +10 -11
- package/src/sources/RpcWebSocketHeightStream.res.mjs +131 -145
- package/src/sources/SimulateSource.res +1 -1
- package/src/sources/SimulateSource.res.mjs +35 -38
- package/src/sources/Source.res +1 -1
- package/src/sources/Source.res.mjs +3 -3
- package/src/sources/SourceManager.res +39 -20
- package/src/sources/SourceManager.res.mjs +340 -371
- package/src/sources/SourceManager.resi +2 -1
- package/src/sources/Svm.res +12 -5
- package/src/sources/Svm.res.mjs +44 -41
- package/src/tui/Tui.res +23 -12
- package/src/tui/Tui.res.mjs +292 -290
- package/src/tui/bindings/Ink.res +2 -4
- package/src/tui/bindings/Ink.res.mjs +35 -41
- package/src/tui/components/BufferedProgressBar.res +7 -7
- package/src/tui/components/BufferedProgressBar.res.mjs +46 -46
- package/src/tui/components/CustomHooks.res +1 -2
- package/src/tui/components/CustomHooks.res.mjs +102 -122
- package/src/tui/components/Messages.res +1 -2
- package/src/tui/components/Messages.res.mjs +38 -42
- package/src/tui/components/SyncETA.res +10 -11
- package/src/tui/components/SyncETA.res.mjs +178 -196
- package/src/tui/components/TuiData.res +1 -1
- package/src/tui/components/TuiData.res.mjs +7 -6
- package/src/vendored/Rest.res +52 -66
- package/src/vendored/Rest.res.mjs +324 -364
- package/svm.schema.json +67 -0
- package/src/Address.gen.ts +0 -8
- package/src/Config.gen.ts +0 -19
- package/src/Envio.gen.ts +0 -55
- package/src/EvmTypes.gen.ts +0 -6
- package/src/InMemoryStore.gen.ts +0 -6
- package/src/Internal.gen.ts +0 -64
- package/src/PgStorage.gen.ts +0 -10
- package/src/PgStorage.res.d.mts +0 -5
- package/src/Types.ts +0 -56
- package/src/bindings/BigDecimal.gen.ts +0 -14
- package/src/bindings/BigDecimal.res.d.mts +0 -5
- package/src/bindings/BigInt.gen.ts +0 -10
- package/src/bindings/BigInt.res +0 -70
- package/src/bindings/BigInt.res.d.mts +0 -5
- package/src/bindings/BigInt.res.mjs +0 -154
- package/src/bindings/Ethers.res.d.mts +0 -5
- package/src/bindings/Pino.gen.ts +0 -17
- package/src/bindings/Postgres.gen.ts +0 -8
- package/src/bindings/Postgres.res.d.mts +0 -5
- package/src/bindings/Promise.res +0 -67
- package/src/bindings/Promise.res.mjs +0 -26
- package/src/db/InternalTable.gen.ts +0 -36
- package/src/sources/HyperSyncClient.gen.ts +0 -19
package/src/LoadLayer.res
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
open Belt
|
|
2
|
-
|
|
3
1
|
let loadById = (
|
|
4
2
|
~loadManager,
|
|
5
3
|
~persistence: Persistence.t,
|
|
@@ -13,12 +11,13 @@ let loadById = (
|
|
|
13
11
|
let inMemTable = inMemoryStore->InMemoryStore.getInMemTable(~entityConfig)
|
|
14
12
|
|
|
15
13
|
let load = async (idsToLoad, ~onError as _) => {
|
|
16
|
-
let
|
|
14
|
+
let storage = persistence->Persistence.getInitializedStorageOrThrow
|
|
15
|
+
let timerRef = Prometheus.StorageLoad.startOperation(~storage=storage.name, ~operation=key)
|
|
17
16
|
|
|
18
17
|
// Since LoadManager.call prevents registerign entities already existing in the inMemoryStore,
|
|
19
18
|
// we can be sure that we load only the new ones.
|
|
20
19
|
let dbEntities = try {
|
|
21
|
-
await
|
|
20
|
+
await storage.loadByIdsOrThrow(
|
|
22
21
|
~table=entityConfig.table,
|
|
23
22
|
~rowsSchema=entityConfig.rowsSchema,
|
|
24
23
|
~ids=idsToLoad,
|
|
@@ -28,15 +27,14 @@ let loadById = (
|
|
|
28
27
|
reason->ErrorHandling.mkLogAndRaise(~logger=item->Logging.getItemLogger, ~msg=message)
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
let entitiesMap =
|
|
30
|
+
let entitiesMap = Dict.make()
|
|
31
|
+
|
|
32
|
+
//Set the entity in the in memory store
|
|
32
33
|
for idx in 0 to dbEntities->Array.length - 1 {
|
|
33
|
-
let entity = dbEntities->
|
|
34
|
-
entitiesMap->
|
|
34
|
+
let entity = dbEntities->Array.getUnsafe(idx)
|
|
35
|
+
entitiesMap->Dict.set(entity.id, entity)
|
|
35
36
|
}
|
|
36
|
-
idsToLoad->
|
|
37
|
-
// Set the entity in the in memory store
|
|
38
|
-
// without overwriting existing values
|
|
39
|
-
// which might be newer than what we got from db
|
|
37
|
+
idsToLoad->Array.forEach(entityId => {
|
|
40
38
|
inMemTable->InMemoryTable.Entity.initValue(
|
|
41
39
|
~allowOverWriteEntity=false,
|
|
42
40
|
~key=entityId,
|
|
@@ -45,6 +43,7 @@ let loadById = (
|
|
|
45
43
|
})
|
|
46
44
|
|
|
47
45
|
timerRef->Prometheus.StorageLoad.endOperation(
|
|
46
|
+
~storage=storage.name,
|
|
48
47
|
~operation=key,
|
|
49
48
|
~whereSize=idsToLoad->Array.length,
|
|
50
49
|
~size=dbEntities->Array.length,
|
|
@@ -90,12 +89,12 @@ let callEffect = (
|
|
|
90
89
|
|
|
91
90
|
effect.handler(arg)
|
|
92
91
|
->Promise.thenResolve(output => {
|
|
93
|
-
inMemTable.dict->
|
|
92
|
+
inMemTable.dict->Dict.set(arg.cacheKey, output)
|
|
94
93
|
if arg.context.cache {
|
|
95
94
|
inMemTable.idsToStore->Array.push(arg.cacheKey)->ignore
|
|
96
95
|
}
|
|
97
96
|
})
|
|
98
|
-
->Promise.catchResolve(exn => {
|
|
97
|
+
->Utils.Promise.catchResolve(exn => {
|
|
99
98
|
onError(~inputKey=arg.cacheKey, ~exn)
|
|
100
99
|
})
|
|
101
100
|
->Promise.finally(() => {
|
|
@@ -143,13 +142,13 @@ let rec executeWithRateLimit = (
|
|
|
143
142
|
~inMemTable,
|
|
144
143
|
~timerRef,
|
|
145
144
|
~onError,
|
|
146
|
-
)->Promise.ignoreValue,
|
|
145
|
+
)->Utils.Promise.ignoreValue,
|
|
147
146
|
)
|
|
148
147
|
->ignore
|
|
149
148
|
}
|
|
150
149
|
|
|
151
150
|
| Some(state) =>
|
|
152
|
-
let now =
|
|
151
|
+
let now = Date.now()
|
|
153
152
|
|
|
154
153
|
// Check if we need to reset the window
|
|
155
154
|
if now >= state.windowStartTime +. state.durationMs->Int.toFloat {
|
|
@@ -159,9 +158,9 @@ let rec executeWithRateLimit = (
|
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
// Split into immediate and queued
|
|
162
|
-
let immediateCount =
|
|
163
|
-
let immediateArgs = effectArgs->Array.slice(~offset=0, ~len=immediateCount)
|
|
164
|
-
let queuedArgs = effectArgs->Array.sliceToEnd(immediateCount)
|
|
161
|
+
let immediateCount = Math.Int.min(state.availableCalls, effectArgs->Array.length)
|
|
162
|
+
let immediateArgs = effectArgs->Belt.Array.slice(~offset=0, ~len=immediateCount)
|
|
163
|
+
let queuedArgs = effectArgs->Belt.Array.sliceToEnd(immediateCount)
|
|
165
164
|
|
|
166
165
|
// Update available calls
|
|
167
166
|
state.availableCalls = state.availableCalls - immediateCount
|
|
@@ -176,7 +175,7 @@ let rec executeWithRateLimit = (
|
|
|
176
175
|
~inMemTable,
|
|
177
176
|
~timerRef,
|
|
178
177
|
~onError,
|
|
179
|
-
)->Promise.ignoreValue,
|
|
178
|
+
)->Utils.Promise.ignoreValue,
|
|
180
179
|
)
|
|
181
180
|
->ignore
|
|
182
181
|
}
|
|
@@ -225,7 +224,7 @@ let rec executeWithRateLimit = (
|
|
|
225
224
|
~isFromQueue=true,
|
|
226
225
|
)
|
|
227
226
|
})
|
|
228
|
-
->Promise.ignoreValue,
|
|
227
|
+
->Utils.Promise.ignoreValue,
|
|
229
228
|
)
|
|
230
229
|
->ignore
|
|
231
230
|
}
|
|
@@ -249,7 +248,7 @@ let loadEffect = (
|
|
|
249
248
|
let inMemTable = inMemoryStore->InMemoryStore.getEffectInMemTable(~effect)
|
|
250
249
|
|
|
251
250
|
let load = async (args, ~onError) => {
|
|
252
|
-
let idsToLoad = args->
|
|
251
|
+
let idsToLoad = args->Array.map((arg: Internal.effectArgs) => arg.cacheKey)
|
|
253
252
|
let idsFromCache = Utils.Set.make()
|
|
254
253
|
|
|
255
254
|
if (
|
|
@@ -258,11 +257,12 @@ let loadEffect = (
|
|
|
258
257
|
| _ => false
|
|
259
258
|
}
|
|
260
259
|
) {
|
|
261
|
-
let
|
|
260
|
+
let storage = persistence->Persistence.getInitializedStorageOrThrow
|
|
261
|
+
let timerRef = Prometheus.StorageLoad.startOperation(~storage=storage.name, ~operation=key)
|
|
262
262
|
let {table, outputSchema} = effect.storageMeta
|
|
263
263
|
|
|
264
264
|
let dbEntities = try {
|
|
265
|
-
await
|
|
265
|
+
await storage.loadByIdsOrThrow(
|
|
266
266
|
~table,
|
|
267
267
|
~rowsSchema=Internal.effectCacheItemRowsSchema,
|
|
268
268
|
~ids=idsToLoad,
|
|
@@ -279,11 +279,11 @@ let loadEffect = (
|
|
|
279
279
|
[]
|
|
280
280
|
}
|
|
281
281
|
|
|
282
|
-
dbEntities->
|
|
282
|
+
dbEntities->Array.forEach(dbEntity => {
|
|
283
283
|
try {
|
|
284
284
|
let output = dbEntity.output->S.parseOrThrow(outputSchema)
|
|
285
285
|
idsFromCache->Utils.Set.add(dbEntity.id)->ignore
|
|
286
|
-
inMemTable.dict->
|
|
286
|
+
inMemTable.dict->Dict.set(dbEntity.id, output)
|
|
287
287
|
} catch {
|
|
288
288
|
| S.Raised(error) =>
|
|
289
289
|
inMemTable.invalidationsCount = inMemTable.invalidationsCount + 1
|
|
@@ -300,6 +300,7 @@ let loadEffect = (
|
|
|
300
300
|
})
|
|
301
301
|
|
|
302
302
|
timerRef->Prometheus.StorageLoad.endOperation(
|
|
303
|
+
~storage=storage.name,
|
|
303
304
|
~operation=key,
|
|
304
305
|
~whereSize=idsToLoad->Array.length,
|
|
305
306
|
~size=dbEntities->Array.length,
|
|
@@ -323,7 +324,7 @@ let loadEffect = (
|
|
|
323
324
|
~inMemTable,
|
|
324
325
|
~onError,
|
|
325
326
|
~isFromQueue=false,
|
|
326
|
-
)->Promise.ignoreValue
|
|
327
|
+
)->Utils.Promise.ignoreValue
|
|
327
328
|
}
|
|
328
329
|
}
|
|
329
330
|
}
|
|
@@ -333,7 +334,7 @@ let loadEffect = (
|
|
|
333
334
|
~load,
|
|
334
335
|
~shouldGroup,
|
|
335
336
|
~hasher=args => args.cacheKey,
|
|
336
|
-
~getUnsafeInMemory=hash => inMemTable.dict->
|
|
337
|
+
~getUnsafeInMemory=hash => inMemTable.dict->Dict.getUnsafe(hash),
|
|
337
338
|
~hasInMemory=hash => inMemTable.dict->Utils.Dict.has(hash),
|
|
338
339
|
~input=effectArgs,
|
|
339
340
|
)
|
|
@@ -360,11 +361,12 @@ let loadByField = (
|
|
|
360
361
|
let inMemTable = inMemoryStore->InMemoryStore.getInMemTable(~entityConfig)
|
|
361
362
|
|
|
362
363
|
let load = async (fieldValues: array<'fieldValue>, ~onError as _) => {
|
|
363
|
-
let
|
|
364
|
+
let storage = persistence->Persistence.getInitializedStorageOrThrow
|
|
365
|
+
let timerRef = Prometheus.StorageLoad.startOperation(~storage=storage.name, ~operation=key)
|
|
364
366
|
|
|
365
367
|
let size = ref(0)
|
|
366
368
|
|
|
367
|
-
let indiciesToLoad = fieldValues->
|
|
369
|
+
let indiciesToLoad = fieldValues->Array.map((fieldValue): TableIndices.Index.t => {
|
|
368
370
|
Single({
|
|
369
371
|
fieldName,
|
|
370
372
|
fieldValue: TableIndices.FieldValue.castFrom(fieldValue),
|
|
@@ -372,59 +374,56 @@ let loadByField = (
|
|
|
372
374
|
})
|
|
373
375
|
})
|
|
374
376
|
|
|
375
|
-
let _ =
|
|
376
|
-
|
|
377
|
-
->
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
)
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
Utils.magic: S.t<'fieldValue> => S.t<TableIndices.FieldValue.t>
|
|
396
|
-
),
|
|
397
|
-
)
|
|
398
|
-
|
|
399
|
-
entities->Array.forEach(entity => {
|
|
400
|
-
//Set the entity in the in memory store
|
|
401
|
-
inMemTable->InMemoryTable.Entity.initValue(
|
|
402
|
-
~allowOverWriteEntity=false,
|
|
403
|
-
~key=entity.id,
|
|
404
|
-
~entity=Some(entity),
|
|
405
|
-
)
|
|
406
|
-
})
|
|
377
|
+
let _ = await indiciesToLoad
|
|
378
|
+
->Array.map(async index => {
|
|
379
|
+
inMemTable->InMemoryTable.Entity.addEmptyIndex(~index)
|
|
380
|
+
try {
|
|
381
|
+
let entities = await storage.loadByFieldOrThrow(
|
|
382
|
+
~operator=switch index {
|
|
383
|
+
| Single({operator: Gt}) => #">"
|
|
384
|
+
| Single({operator: Eq}) => #"="
|
|
385
|
+
| Single({operator: Lt}) => #"<"
|
|
386
|
+
},
|
|
387
|
+
~table=entityConfig.table,
|
|
388
|
+
~rowsSchema=entityConfig.rowsSchema,
|
|
389
|
+
~fieldName=index->TableIndices.Index.getFieldName,
|
|
390
|
+
~fieldValue=switch index {
|
|
391
|
+
| Single({fieldValue}) => fieldValue
|
|
392
|
+
},
|
|
393
|
+
~fieldSchema=fieldValueSchema->(
|
|
394
|
+
Utils.magic: S.t<'fieldValue> => S.t<TableIndices.FieldValue.t>
|
|
395
|
+
),
|
|
396
|
+
)
|
|
407
397
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
~
|
|
413
|
-
~logger=item->Logging.getItemLogger,
|
|
414
|
-
~params={
|
|
415
|
-
"operator": operatorCallName,
|
|
416
|
-
"tableName": entityConfig.table.tableName,
|
|
417
|
-
"fieldName": fieldName,
|
|
418
|
-
"fieldValue": fieldValue,
|
|
419
|
-
},
|
|
420
|
-
),
|
|
421
|
-
~msg=message,
|
|
398
|
+
entities->Array.forEach(entity => {
|
|
399
|
+
inMemTable->InMemoryTable.Entity.initValue(
|
|
400
|
+
~allowOverWriteEntity=false,
|
|
401
|
+
~key=entity.id,
|
|
402
|
+
~entity=Some(entity),
|
|
422
403
|
)
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
size := size.contents + entities->Array.length
|
|
407
|
+
} catch {
|
|
408
|
+
| Persistence.StorageError({message, reason}) =>
|
|
409
|
+
reason->ErrorHandling.mkLogAndRaise(
|
|
410
|
+
~logger=Logging.createChildFrom(
|
|
411
|
+
~logger=item->Logging.getItemLogger,
|
|
412
|
+
~params={
|
|
413
|
+
"operator": operatorCallName,
|
|
414
|
+
"tableName": entityConfig.table.tableName,
|
|
415
|
+
"fieldName": fieldName,
|
|
416
|
+
"fieldValue": fieldValue,
|
|
417
|
+
},
|
|
418
|
+
),
|
|
419
|
+
~msg=message,
|
|
420
|
+
)
|
|
421
|
+
}
|
|
422
|
+
})
|
|
423
|
+
->Promise.all
|
|
426
424
|
|
|
427
425
|
timerRef->Prometheus.StorageLoad.endOperation(
|
|
426
|
+
~storage=storage.name,
|
|
428
427
|
~operation=key,
|
|
429
428
|
~whereSize=fieldValues->Array.length,
|
|
430
429
|
~size=size.contents,
|