Skip to content

Commit 3a56c36

Browse files
committed
feat(security): modernize remaining ReScript APIs in registry and playground
1 parent bde5fd1 commit 3a56c36

6 files changed

Lines changed: 157 additions & 157 deletions

File tree

playground/src/Formatter.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let clauseStarters = [
1111
let formatVql = (query: string): string => {
1212
let upper = String.toUpperCase
1313
let tokens =
14-
Js.String2.splitByRe(query, %re("/(\s+|'[^']*'|\"[^\"]*\")/"))
14+
String.splitByRe(query, %re("/(\s+|'[^']*'|\"[^\"]*\")/"))
1515
->Array.filterMap(t => t)
1616
->Array.filter(t => String.trim(t) !== "")
1717

playground/src/Linter.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let lint = (query: string, ~vqlDt: bool=false): array<diagnostic> => {
2020
let diagnostics = []
2121
let upper = String.toUpperCase(query)
2222
let tokens =
23-
Js.String2.splitByRe(String.trim(upper), %re("/\s+/"))
23+
String.splitByRe(String.trim(upper), %re("/\s+/"))
2424
->Array.filterMap(x => x)
2525

2626
let has = tok => tokens->Array.includes(tok)

src/registry/KRaftCluster.res

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ let handleAppendEntriesResponse = (
265265
} else if state.raft.role == Leader {
266266
if response.success {
267267
// Update nextIndex and matchIndex for the follower
268-
let nextIndex = Js.Dict.fromArray(Js.Dict.entries(state.raft.nextIndex))
269-
let matchIndex = Js.Dict.fromArray(Js.Dict.entries(state.raft.matchIndex))
268+
let nextIndex = Dict.fromArray(Dict.entries(state.raft.nextIndex))
269+
let matchIndex = Dict.fromArray(Dict.entries(state.raft.matchIndex))
270270

271-
Js.Dict.set(nextIndex, fromPeer, response.matchIndex + 1)
272-
Js.Dict.set(matchIndex, fromPeer, response.matchIndex)
271+
Dict.set(nextIndex, fromPeer, response.matchIndex + 1)
272+
Dict.set(matchIndex, fromPeer, response.matchIndex)
273273

274274
let raft = {...state.raft, nextIndex: nextIndex, matchIndex: matchIndex}
275275
// Try to advance commit index
@@ -278,10 +278,10 @@ let handleAppendEntriesResponse = (
278278
{...state, raft: raft}
279279
} else {
280280
// Decrement nextIndex for the follower and retry
281-
let nextIndex = Js.Dict.fromArray(Js.Dict.entries(state.raft.nextIndex))
281+
let nextIndex = Dict.fromArray(Dict.entries(state.raft.nextIndex))
282282
let currentNext =
283-
Js.Dict.get(nextIndex, fromPeer)->Belt.Option.getWithDefault(1)
284-
Js.Dict.set(nextIndex, fromPeer, Js.Math.max_int(currentNext - 1, 1))
283+
Dict.get(nextIndex, fromPeer)->Belt.Option.getWithDefault(1)
284+
Dict.set(nextIndex, fromPeer, Js.Math.max_int(currentNext - 1, 1))
285285

286286
{...state, raft: {...state.raft, nextIndex: nextIndex}}
287287
}
@@ -354,7 +354,7 @@ let proposeUpdateTrust = (
354354
let proposeMapHexad = (
355355
state: clusterState,
356356
hexadId: string,
357-
locations: Js.Dict.t<Js.Json.t>,
357+
locations: Dict.t<Js.Json.t>,
358358
): (clusterState, clientResult) => {
359359
propose(
360360
state,
@@ -377,21 +377,21 @@ let applyCommand = (registry: Registry.registryState, command: MetadataLog.comma
377377

378378
| UnregisterStore({storeId}) => {
379379
// Remove store from registry
380-
let newStores = Js.Dict.fromArray(
381-
Js.Dict.entries(registry.stores)->Belt.Array.keep(((id, _)) => id != storeId),
380+
let newStores = Dict.fromArray(
381+
Dict.entries(registry.stores)->Belt.Array.keep(((id, _)) => id != storeId),
382382
)
383383
{...registry, stores: newStores}
384384
}
385385

386386
| MapHexad({hexadId, locations}) => {
387387
// Convert JSON locations to storeLocation dict
388388
// In production, would deserialize properly
389-
Registry.map(registry, hexadId, Js.Dict.empty())
389+
Registry.map(registry, hexadId, Dict.empty())
390390
}
391391

392392
| UnmapHexad({hexadId}) => {
393-
let newMappings = Js.Dict.fromArray(
394-
Js.Dict.entries(registry.mappings)->Belt.Array.keep(((id, _)) => id != hexadId),
393+
let newMappings = Dict.fromArray(
394+
Dict.entries(registry.mappings)->Belt.Array.keep(((id, _)) => id != hexadId),
395395
)
396396
{...registry, mappings: newMappings}
397397
}
@@ -520,8 +520,8 @@ let diagnostics = (state: clusterState): clusterDiagnostics => {
520520
logLength: Belt.Array.length(state.raft.log),
521521
peerCount: Belt.Array.length(state.config.peers),
522522
leaderId: state.leaderId,
523-
registeredStores: Belt.Array.length(Js.Dict.keys(state.registry.stores)),
524-
mappedHexads: Belt.Array.length(Js.Dict.keys(state.registry.mappings)),
523+
registeredStores: Belt.Array.length(Dict.keys(state.registry.stores)),
524+
mappedHexads: Belt.Array.length(Dict.keys(state.registry.mappings)),
525525
totalCommitted: state.totalCommitted,
526526
totalApplied: state.totalApplied,
527527
electionCount: state.electionCount,

0 commit comments

Comments
 (0)