Skip to content

Commit 0e3da42

Browse files
committed
linting and version update
1 parent 68ef0bf commit 0e3da42

File tree

8 files changed

+116
-48
lines changed

8 files changed

+116
-48
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.10.1
1+
0.11.0

Directory.Build.props

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>0.10.1</Version>
4-
<AssemblyVersion>0.10.1.0</AssemblyVersion>
5-
<FileVersion>0.10.1.0</FileVersion>
3+
<Version>0.11.0</Version>
4+
<AssemblyVersion>0.11.0.0</AssemblyVersion>
5+
<FileVersion>0.11.0.0</FileVersion>
66
</PropertyGroup>
77
</Project>

Neo4jExport/src/Export/BatchProcessing.fs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ let private tryGetNodes (startVal: obj) (endVal: obj) =
112112
try
113113
let startNode = startVal.As<INode>()
114114
let endNode = endVal.As<INode>()
115-
Ok (startNode, endNode)
115+
Ok(startNode, endNode)
116116
with ex ->
117117
Error ex
118118

@@ -170,17 +170,18 @@ let processRelationshipRecord (buffer: ArrayBufferWriter<byte>) record exportId
170170
match tryGetRelationship record, record.TryGetValue("s"), record.TryGetValue("t") with
171171
| Ok rel, (true, startVal), (true, endVal) ->
172172
// Phase 1 & 2: Extract IDs directly from relationship first (safe operation)
173-
let struct (relId, startId, endId, relType, idsExtracted) = tryExtractRelationshipIdsDirectly rel
174-
173+
let struct (relId, startId, endId, relType, idsExtracted) =
174+
tryExtractRelationshipIdsDirectly rel
175+
175176
// Phase 3: Try to get nodes for full serialization
176177
match tryGetNodes startVal endVal with
177-
| Ok (startNode, endNode) ->
178+
| Ok(startNode, endNode) ->
178179
// We have nodes, use them for full serialization
179180
let ids =
180181
{ ElementId = relId
181182
StartElementId = startId
182183
EndElementId = endId }
183-
184+
184185
writeRelationship writer rel ids ctx
185186
| Error ex ->
186187
// Phase 4: Node casting failed, but we already have IDs from the relationship
@@ -196,7 +197,15 @@ let processRelationshipRecord (buffer: ArrayBufferWriter<byte>) record exportId
196197
writer.WriteString("type", "relationship")
197198
writer.WriteString("element_id", relId)
198199
writer.WriteString("export_id", ctx.ExportId.ToString())
199-
writer.WriteString("label", if String.IsNullOrEmpty(relType) then "_UNKNOWN" else relType)
200+
201+
writer.WriteString(
202+
"label",
203+
if String.IsNullOrEmpty(relType) then
204+
"_UNKNOWN"
205+
else
206+
relType
207+
)
208+
200209
writer.WriteString("start_element_id", startId)
201210
writer.WriteString("end_element_id", endId)
202211
writer.WriteStartObject "properties"

Neo4jExport/src/Export/Core.fs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@ let exportNodesUnified
6161

6262
let nodeHandler (state: NodeExportState) (record: IRecord) (bytesWritten: int64) : NodeExportState =
6363
errorTracker.IncrementLine()
64-
65-
let newLineState = state.LineState |> LineTracking.incrementLine
64+
65+
let newLineState =
66+
state.LineState |> LineTracking.incrementLine
6667

6768
let labels =
6869
try
@@ -121,15 +122,20 @@ let exportRelationships
121122
Log.info "Exporting relationships..."
122123

123124
let initialState: RelationshipExportState =
124-
lineState |> LineTracking.recordTypeStart "relationship"
125+
lineState
126+
|> LineTracking.recordTypeStart "relationship"
125127

126128
let processor =
127129
{ Query = "MATCH (s)-[r]->(t) RETURN r, s, t SKIP $skip LIMIT $limit"
128130
GetTotalQuery = Some "MATCH ()-[r]->() RETURN count(r) as count"
129131
ProcessRecord = processRelationshipRecord
130132
EntityName = "Relationships" }
131133

132-
let relationshipHandler (state: RelationshipExportState) (record: IRecord) (bytesWritten: int64) : RelationshipExportState =
134+
let relationshipHandler
135+
(state: RelationshipExportState)
136+
(record: IRecord)
137+
(bytesWritten: int64)
138+
: RelationshipExportState =
133139
errorTracker.IncrementLine()
134140
state |> LineTracking.incrementLine
135141

Neo4jExport/src/JsonHelpers.fs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,13 @@ module JsonHelpers =
101101
match toJsonValue obj with
102102
| Ok value -> value
103103
| Error msg ->
104-
logWarning (sprintf "JSON conversion failed for type '%s', using default value. Error: %s" (obj.GetType().FullName) msg)
104+
logWarning (
105+
sprintf
106+
"JSON conversion failed for type '%s', using default value. Error: %s"
107+
(obj.GetType().FullName)
108+
msg
109+
)
110+
105111
defaultValue
106112

107113
/// Extract string value from JsonValue - Result version

Neo4jExport/src/Metadata.fs

Lines changed: 71 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,12 @@ module Metadata =
3131
[<Literal>]
3232
let private FORMAT_VERSION = "1.0.0"
3333

34-
let private collectDatabaseInfo (session: SafeSession) (breaker: Neo4j.CircuitBreaker) (config: ExportConfig) (errorTracker: ErrorTracking.ErrorTracker) =
34+
let private collectDatabaseInfo
35+
(session: SafeSession)
36+
(breaker: Neo4j.CircuitBreaker)
37+
(config: ExportConfig)
38+
(errorTracker: ErrorTracking.ErrorTracker)
39+
=
3540
async {
3641
let info = Dictionary<string, JsonValue>()
3742

@@ -55,13 +60,17 @@ module Metadata =
5560
info.["version"] <- JString "unknown"
5661
info.["edition"] <- JString "unknown"
5762
| Error e ->
58-
let msg = sprintf "Failed to retrieve database version info: %A" e
63+
let msg =
64+
sprintf "Failed to retrieve database version info: %A" e
65+
5966
Log.warn msg
6067
errorTracker.AddWarning(msg)
6168
info.["version"] <- JString "unknown"
6269
info.["edition"] <- JString "unknown"
6370
with ex ->
64-
let msg = sprintf "Exception while collecting database info: %s" ex.Message
71+
let msg =
72+
sprintf "Exception while collecting database info: %s" ex.Message
73+
6574
Log.warn msg
6675
errorTracker.AddWarning(msg)
6776
info.["version"] <- JString "unknown"
@@ -82,17 +91,23 @@ module Metadata =
8291
match records with
8392
| [ name ] -> info.["database_name"] <- JString name
8493
| _ ->
85-
let msg = "Could not retrieve database name, using default"
94+
let msg =
95+
"Could not retrieve database name, using default"
96+
8697
Log.warn msg
8798
errorTracker.AddWarning(msg)
8899
info.["database_name"] <- JString "neo4j"
89100
| Error e ->
90-
let msg = sprintf "Failed to retrieve database name: %A" e
101+
let msg =
102+
sprintf "Failed to retrieve database name: %A" e
103+
91104
Log.warn msg
92105
errorTracker.AddWarning(msg)
93106
info.["database_name"] <- JString "neo4j"
94107
with ex ->
95-
let msg = sprintf "Exception while retrieving database name: %s" ex.Message
108+
let msg =
109+
sprintf "Exception while retrieving database name: %s" ex.Message
110+
96111
Log.warn msg
97112
errorTracker.AddWarning(msg)
98113
info.["database_name"] <- JString "neo4j"
@@ -101,7 +116,12 @@ module Metadata =
101116
return Ok(info :> IDictionary<string, JsonValue>)
102117
}
103118

104-
let private collectStatistics (session: SafeSession) (breaker: Neo4j.CircuitBreaker) (config: ExportConfig) (errorTracker: ErrorTracking.ErrorTracker) =
119+
let private collectStatistics
120+
(session: SafeSession)
121+
(breaker: Neo4j.CircuitBreaker)
122+
(config: ExportConfig)
123+
(errorTracker: ErrorTracking.ErrorTracker)
124+
=
105125
async {
106126
Log.info "Collecting database statistics..."
107127
let stats = Dictionary<string, JsonValue>()
@@ -137,13 +157,17 @@ module Metadata =
137157
stats.["nodeCount"] <- JNumber 0M
138158
stats.["relCount"] <- JNumber 0M
139159
| Error e ->
140-
let msg = sprintf "Failed to collect statistics: %A" e
160+
let msg =
161+
sprintf "Failed to collect statistics: %A" e
162+
141163
Log.warn msg
142164
errorTracker.AddWarning(msg)
143165
stats.["nodeCount"] <- JNumber 0M
144166
stats.["relCount"] <- JNumber 0M
145167
with ex ->
146-
let msg = sprintf "Exception while collecting statistics: %s" ex.Message
168+
let msg =
169+
sprintf "Exception while collecting statistics: %s" ex.Message
170+
147171
Log.warn msg
148172
errorTracker.AddWarning(msg)
149173
stats.["nodeCount"] <- JNumber 0M
@@ -154,15 +178,22 @@ module Metadata =
154178
return Ok(stats :> IDictionary<string, JsonValue>)
155179
}
156180

157-
let private collectSchema (session: SafeSession) (breaker: Neo4j.CircuitBreaker) (config: ExportConfig) (errorTracker: ErrorTracking.ErrorTracker) =
181+
let private collectSchema
182+
(session: SafeSession)
183+
(breaker: Neo4j.CircuitBreaker)
184+
(config: ExportConfig)
185+
(errorTracker: ErrorTracking.ErrorTracker)
186+
=
158187
async {
159188
if config.SkipSchemaCollection then
160189
Log.info "Skipping schema collection (disabled by configuration)"
161190
return Ok(dict [])
162191
else
163192
Log.info "Collecting basic schema information..."
164193
let schema = Dictionary<string, JsonValue>()
165-
let jsonConversionError = JString "serialization_error" // A sensible default
194+
195+
let jsonConversionError =
196+
JString "serialization_error" // A sensible default
166197

167198
try
168199
let! result =
@@ -177,18 +208,24 @@ module Metadata =
177208
match result with
178209
| Ok records ->
179210
match records with
180-
| [ labels ] ->
211+
| [ labels ] ->
181212
schema.["labels"] <- JsonHelpers.toJsonValueWithDefault jsonConversionError Log.warn labels
182-
| _ ->
183-
let msg = "Failed to collect database labels: unexpected result count"
213+
| _ ->
214+
let msg =
215+
"Failed to collect database labels: unexpected result count"
216+
184217
Log.warn msg
185218
errorTracker.AddWarning(msg)
186-
| Error e ->
187-
let msg = sprintf "Failed to collect database labels: %A" e
219+
| Error e ->
220+
let msg =
221+
sprintf "Failed to collect database labels: %A" e
222+
188223
Log.warn msg
189224
errorTracker.AddWarning(msg)
190225
with ex ->
191-
let msg = sprintf "Exception while collecting labels: %s" ex.Message
226+
let msg =
227+
sprintf "Exception while collecting labels: %s" ex.Message
228+
192229
Log.warn msg
193230
errorTracker.AddWarning(msg)
194231

@@ -205,18 +242,25 @@ module Metadata =
205242
match result with
206243
| Ok records ->
207244
match records with
208-
| [ types ] ->
209-
schema.["relationshipTypes"] <- JsonHelpers.toJsonValueWithDefault jsonConversionError Log.warn types
210-
| _ ->
211-
let msg = "Failed to collect relationship types: unexpected result count"
245+
| [ types ] ->
246+
schema.["relationshipTypes"] <-
247+
JsonHelpers.toJsonValueWithDefault jsonConversionError Log.warn types
248+
| _ ->
249+
let msg =
250+
"Failed to collect relationship types: unexpected result count"
251+
212252
Log.warn msg
213253
errorTracker.AddWarning(msg)
214-
| Error e ->
215-
let msg = sprintf "Failed to collect relationship types: %A" e
254+
| Error e ->
255+
let msg =
256+
sprintf "Failed to collect relationship types: %A" e
257+
216258
Log.warn msg
217259
errorTracker.AddWarning(msg)
218260
with ex ->
219-
let msg = sprintf "Exception while collecting relationship types: %s" ex.Message
261+
let msg =
262+
sprintf "Exception while collecting relationship types: %s" ex.Message
263+
220264
Log.warn msg
221265
errorTracker.AddWarning(msg)
222266

@@ -286,7 +330,9 @@ module Metadata =
286330
else
287331
st.["relTypeCount"] <- JNumber 0M
288332

289-
let! scriptChecksum = Utils.getScriptChecksum (AppContext.getCancellationToken context) |> Async.AwaitTask
333+
let! scriptChecksum =
334+
Utils.getScriptChecksum (AppContext.getCancellationToken context)
335+
|> Async.AwaitTask
290336

291337
let exportScript =
292338
{ Name = Path.GetFileName(System.Reflection.Assembly.GetExecutingAssembly().Location)

Neo4jExport/src/SignalHandling.fs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ module SignalHandling =
5050
Log.warn "Received SIGTERM signal, requesting shutdown..."
5151
AppContext.cancel context)
5252
)
53-
53+
5454
Some(sigtermRegistration :> IDisposable)
5555
#else
5656
let registerSigtermFallback () =
@@ -79,10 +79,11 @@ module SignalHandling =
7979
Log.warn "Received SIGTERM signal, requesting shutdown..."
8080
AppContext.cancel context)
8181

82-
let registration = createMethod.Invoke(null, [| sigterm; box handler |])
83-
82+
let registration =
83+
createMethod.Invoke(null, [| sigterm; box handler |])
84+
8485
Log.debug "SIGTERM handler registered via reflection"
85-
86+
8687
// Check if the result implements IDisposable
8788
match registration with
8889
| :? IDisposable as disposable -> Some disposable

Neo4jExport/src/Types.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ type SerializationError =
6363
/// This is intentionally designed for metadata where JSON fidelity matters more than .NET type fidelity.
6464
type JsonValue =
6565
| JString of string
66-
| JNumber of decimal // All numeric types converted to decimal for JSON compatibility
66+
| JNumber of decimal // All numeric types converted to decimal for JSON compatibility
6767
| JBool of bool
6868
| JNull
6969
| JObject of IDictionary<string, JsonValue>
@@ -185,14 +185,14 @@ type ApplicationContext =
185185
| :? System.InvalidOperationException ->
186186
// Process was already disposed
187187
(false, 0)
188-
| _ ->
189-
(false, 0)
190-
188+
| _ -> (false, 0)
189+
191190
if canAccessProperties then
192191
// We can safely access properties
193192
try
194193
if not proc.HasExited then
195194
proc.Kill()
195+
196196
proc.Dispose()
197197
with ex ->
198198
eprintfn "[WARN] Failed to terminate/dispose process (PID %d): %s" processId ex.Message

0 commit comments

Comments
 (0)