Skip to content

Commit af0268e

Browse files
Home db cache (#833)
* Refactor auth tokens * Initial implementation of cache * Add supported feature for Bolt 5.8 and fix cache key for home database * Enhance routing and connection pool interfaces to support home database caching and SSR configuration * Fix for Stefan's category/classification issue in WithNotifications, some tidying, moved GQL Notifications out of preview * Add test for WithNotifications to set multiple categories and classifications * Refactor NotificationsConfig to handle null disabled categories and classifications * Update tests to assert DisabledCategories is empty instead of null * Cache key now working? * Refactor authentication token handling and update tests for response handlers * Get unit tests working * pre cache refactor * Refactor logging output format and introduce ConsoleTextWriter for enhanced console output * testkit tests looking good * Enhance BeginResponseHandler and RunResponseHandler to support default database flag * Unit tests all fixed * Review notes bugs fixed * HomeDbCache cache purging * Add support for Bolt protocol version 5.8 * fix failing tests * maybe fix testkit? * Add exception detail to aid in debugging testkit failures * Fix failing testkit tests * Implement IsDirectDriver property in connection provider and related classes * LoadBalancer fix for mixed clusters * Fix logic in "dance" * fix testkit tests?
1 parent 0f8f4ba commit af0268e

File tree

363 files changed

+5002
-3641
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

363 files changed

+5002
-3641
lines changed

Neo4j.Driver/.editorconfig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ dotnet_naming_symbols.types_and_namespaces_symbols.applicable_kinds = namespace,
369369
dotnet_naming_symbols.type_parameters_symbols.applicable_accessibilities = *
370370
dotnet_naming_symbols.type_parameters_symbols.applicable_kinds = type_parameter
371371
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_accessibilities = *
372-
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
372+
dotnet_naming_symbols.unity_serialized_field_symbols.applicable_kinds =
373373
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_applicable_kinds = unity_serialised_field
374374
dotnet_naming_symbols.unity_serialized_field_symbols.resharper_required_modifiers = instance
375375
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_accessibilities = *
376-
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_kinds =
376+
dotnet_naming_symbols.unity_serialized_field_symbols_1.applicable_kinds =
377377
dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_applicable_kinds = unity_serialised_field
378378
dotnet_naming_symbols.unity_serialized_field_symbols_1.resharper_required_modifiers = instance
379379
dotnet_separate_import_directive_groups = false
@@ -663,8 +663,8 @@ resharper_line_break_before_requires_clause = do_not_change
663663
resharper_linkage_specification_braces = end_of_line
664664
resharper_linkage_specification_indentation = none
665665
resharper_local_function_body = block_body
666-
resharper_macro_block_begin =
667-
resharper_macro_block_end =
666+
resharper_macro_block_begin =
667+
resharper_macro_block_end =
668668
resharper_max_array_initializer_elements_on_line = 10000
669669
resharper_max_attribute_length_for_same_line = 38
670670
resharper_max_enum_members_on_line = 1
@@ -734,7 +734,7 @@ resharper_resx_attribute_indent = single_indent
734734
resharper_resx_blank_line_after_pi = true
735735
resharper_resx_indent_text = OneIndent
736736
resharper_resx_keep_user_linebreaks = true
737-
resharper_resx_linebreak_before_elements =
737+
resharper_resx_linebreak_before_elements =
738738
resharper_resx_max_blank_lines_between_tags = 0
739739
resharper_resx_pi_attribute_style = do_not_touch
740740
resharper_resx_space_before_self_closing = false
@@ -963,7 +963,7 @@ resharper_xml_attribute_indent = align_by_first_attribute
963963
resharper_xml_blank_line_after_pi = true
964964
resharper_xml_indent_text = OneIndent
965965
resharper_xml_keep_user_linebreaks = true
966-
resharper_xml_linebreak_before_elements =
966+
resharper_xml_linebreak_before_elements =
967967
resharper_xml_max_blank_lines_between_tags = 2
968968
resharper_xml_pi_attribute_style = do_not_touch
969969
resharper_xml_space_before_self_closing = true

Neo4j.Driver/Neo4j.Driver.Tests.BenchkitBackend/Abstractions/IWorkloadExecutor.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,10 @@
1717

1818
namespace Neo4j.Driver.Tests.BenchkitBackend.Abstractions;
1919

20-
/// <summary>
21-
/// Defines methods for executing a workload.
22-
/// </summary>
20+
/// <summary>Defines methods for executing a workload.</summary>
2321
public interface IWorkloadExecutor
2422
{
25-
/// <summary>
26-
/// Execute a workload.
27-
/// </summary>
23+
/// <summary>Execute a workload.</summary>
2824
/// <param name="workload">The workload to execute.</param>
2925
/// <returns>A task that completes when the workload has been executed.</returns>
3026
Task ExecuteWorkloadAsync(Workload workload);
Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Copyright (c) "Neo4j"
22
// Neo4j Sweden AB [https://neo4j.com]
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License").
55
// You may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
7-
//
7+
//
88
// http://www.apache.org/licenses/LICENSE-2.0
9-
//
9+
//
1010
// Unless required by applicable law or agreed to in writing, software
1111
// distributed under the License is distributed on an "AS IS" BASIS,
1212
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,14 +17,10 @@
1717

1818
namespace Neo4j.Driver.Tests.BenchkitBackend.Abstractions;
1919

20-
/// <summary>
21-
/// Methods for forwarding a workload to the correct executor.
22-
/// </summary>
20+
/// <summary>Methods for forwarding a workload to the correct executor.</summary>
2321
public interface IWorkloadExecutorSelector
2422
{
25-
/// <summary>
26-
/// Gets the correct executor for the workload.
27-
/// </summary>
23+
/// <summary>Gets the correct executor for the workload.</summary>
2824
/// <param name="workload">The workload to execute.</param>
2925
public IWorkloadExecutor GetExecutor(Workload workload);
3026
}
Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Copyright (c) "Neo4j"
22
// Neo4j Sweden AB [https://neo4j.com]
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License").
55
// You may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
7-
//
7+
//
88
// http://www.apache.org/licenses/LICENSE-2.0
9-
//
9+
//
1010
// Unless required by applicable law or agreed to in writing, software
1111
// distributed under the License is distributed on an "AS IS" BASIS,
1212
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,41 +17,29 @@
1717

1818
namespace Neo4j.Driver.Tests.BenchkitBackend.Abstractions;
1919

20-
/// <summary>
21-
/// Represents a store for managing workloads.
22-
/// </summary>
20+
/// <summary>Represents a store for managing workloads.</summary>
2321
public interface IWorkloadStore
2422
{
25-
/// <summary>
26-
/// Creates a new workload in the store.
27-
/// </summary>
23+
/// <summary>Creates a new workload in the store.</summary>
2824
/// <param name="workload">The workload to create.</param>
2925
/// <returns>The ID of the created workload.</returns>
3026
string CreateWorkload(Workload workload);
3127

32-
/// <summary>
33-
/// Retrieves a workload from the store.
34-
/// </summary>
28+
/// <summary>Retrieves a workload from the store.</summary>
3529
/// <param name="id">The ID of the workload to retrieve.</param>
3630
/// <returns>The retrieved workload.</returns>
3731
Workload GetWorkload(string id);
3832

39-
/// <summary>
40-
/// Updates a workload in the store.
41-
/// </summary>
33+
/// <summary>Updates a workload in the store.</summary>
4234
/// <param name="id">The ID of the workload to update.</param>
4335
/// <param name="workload">The updated workload.</param>
4436
/// <returns>The updated workload.</returns>
4537
Workload UpdateWorkload(string id, Workload workload);
4638

47-
/// <summary>
48-
/// Deletes a workload from the store.
49-
/// </summary>
39+
/// <summary>Deletes a workload from the store.</summary>
5040
/// <param name="id">The ID of the workload to delete.</param>
5141
void DeleteWorkload(string id);
5242

53-
/// <summary>
54-
/// Retrieves the full list of workloads from the store.
55-
/// </summary>
43+
/// <summary>Retrieves the full list of workloads from the store.</summary>
5644
IDictionary<string, Workload> GetAllWorkloads();
5745
}

Neo4j.Driver/Neo4j.Driver.Tests.BenchkitBackend/Controllers/ReadyController.cs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Copyright (c) "Neo4j"
22
// Neo4j Sweden AB [https://neo4j.com]
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License").
55
// You may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
7-
//
7+
//
88
// http://www.apache.org/licenses/LICENSE-2.0
9-
//
9+
//
1010
// Unless required by applicable law or agreed to in writing, software
1111
// distributed under the License is distributed on an "AS IS" BASIS,
1212
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,9 +19,7 @@ namespace Neo4j.Driver.Tests.BenchkitBackend.Controllers;
1919

2020
using ILogger = Microsoft.Extensions.Logging.ILogger;
2121

22-
/// <summary>
23-
/// Check if the service is ready.
24-
/// </summary>
22+
/// <summary>Check if the service is ready.</summary>
2523
[ApiController]
2624
[Route("[controller]")]
2725
public class ReadyController(
@@ -30,12 +28,10 @@ public class ReadyController(
3028
: ControllerBase
3129
{
3230
// GET
33-
/// <summary>
34-
/// Check if the service is ready.
35-
/// </summary>
31+
/// <summary>Check if the service is ready.</summary>
3632
/// <remarks>
37-
/// This endpoint can be used to check if the service is ready to receive requests. This obviously includes
38-
/// the web server, but also whether the backend can successfully connect to the DBMS.
33+
/// This endpoint can be used to check if the service is ready to receive requests. This obviously includes the
34+
/// web server, but also whether the backend can successfully connect to the DBMS.
3935
/// </remarks>
4036
[HttpGet]
4137
[ProducesResponseType(StatusCodes.Status204NoContent)]

Neo4j.Driver/Neo4j.Driver.Tests.BenchkitBackend/Controllers/WorkloadController.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,14 @@ namespace Neo4j.Driver.Tests.BenchkitBackend.Controllers;
2121

2222
using ILogger = Microsoft.Extensions.Logging.ILogger;
2323

24-
/// <summary>
25-
/// Define and run workloads in the Neo4j driver.
26-
/// </summary>
24+
/// <summary>Define and run workloads in the Neo4j driver.</summary>
2725
[ApiController]
2826
[Route("[controller]")]
2927
public class WorkloadController(
30-
IWorkloadStore workloadStore,
31-
IWorkloadExecutorSelector workloadExecutorSelector,
32-
ILogger logger,
33-
LinkGenerator linkGenerator)
28+
IWorkloadStore workloadStore,
29+
IWorkloadExecutorSelector workloadExecutorSelector,
30+
ILogger logger,
31+
LinkGenerator linkGenerator)
3432
: ControllerBase
3533
{
3634
// GET
@@ -95,8 +93,7 @@ public async Task<ActionResult> ExecuteEphemeral([FromBody] Workload workload)
9593

9694
// DELETE
9795
/// <summary>Deletes a driver workload.</summary>
98-
/// <remarks>This endpoint deletes the workload from memory. Ongoing executions will not be
99-
/// canceled or stopped.</remarks>
96+
/// <remarks>This endpoint deletes the workload from memory. Ongoing executions will not be canceled or stopped.</remarks>
10097
[HttpDelete("{id}")]
10198
[ProducesResponseType(StatusCodes.Status204NoContent)]
10299
[ProducesResponseType(StatusCodes.Status404NotFound)]

Neo4j.Driver/Neo4j.Driver.Tests.BenchkitBackend/Implementations/ExecuteQueryWorkloadExecutor.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Copyright (c) "Neo4j"
22
// Neo4j Sweden AB [https://neo4j.com]
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License").
55
// You may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
7-
//
7+
//
88
// http://www.apache.org/licenses/LICENSE-2.0
9-
//
9+
//
1010
// Unless required by applicable law or agreed to in writing, software
1111
// distributed under the License is distributed on an "AS IS" BASIS,
1212
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,9 +21,9 @@ namespace Neo4j.Driver.Tests.BenchkitBackend.Implementations;
2121
using ILogger = Microsoft.Extensions.Logging.ILogger;
2222

2323
internal class ExecuteQueryWorkloadExecutor(
24-
IDriver driver,
25-
IRecordConsumer recordConsumer,
26-
ILogger logger)
24+
IDriver driver,
25+
IRecordConsumer recordConsumer,
26+
ILogger logger)
2727
: IWorkloadExecutor
2828
{
2929
public async Task ExecuteWorkloadAsync(Workload workload)

Neo4j.Driver/Neo4j.Driver.Tests.BenchkitBackend/Implementations/ExecuteReadWriteWorkloadExecutor.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ namespace Neo4j.Driver.Tests.BenchkitBackend.Implementations;
2121
using ILogger = Microsoft.Extensions.Logging.ILogger;
2222

2323
internal class ExecuteReadWriteWorkloadExecutor(
24-
IDriver driver,
25-
IRecordConsumer recordConsumer,
26-
IWorkloadSessionBuilder sessionBuilder,
27-
ILogger logger)
24+
IDriver driver,
25+
IRecordConsumer recordConsumer,
26+
IWorkloadSessionBuilder sessionBuilder,
27+
ILogger logger)
2828
: IWorkloadExecutor
2929
{
3030
public async Task ExecuteWorkloadAsync(Workload workload)
@@ -145,7 +145,7 @@ await execute(
145145

146146
return 0;
147147
},
148-
_ => { });
148+
_ => {});
149149

150150
logger.LogDebug("Workload completed");
151151
}

Neo4j.Driver/Neo4j.Driver.Tests.BenchkitBackend/Implementations/RecordConsumer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Copyright (c) "Neo4j"
22
// Neo4j Sweden AB [https://neo4j.com]
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License").
55
// You may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
7-
//
7+
//
88
// http://www.apache.org/licenses/LICENSE-2.0
9-
//
9+
//
1010
// Unless required by applicable law or agreed to in writing, software
1111
// distributed under the License is distributed on an "AS IS" BASIS,
1212
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,7 +20,7 @@ namespace Neo4j.Driver.Tests.BenchkitBackend.Implementations;
2020
using ILogger = Microsoft.Extensions.Logging.ILogger;
2121

2222
internal class RecordConsumer(
23-
ILogger logger)
23+
ILogger logger)
2424
: IRecordConsumer
2525
{
2626
public void ConsumeRecords(IEnumerable<IRecord> records)

Neo4j.Driver/Neo4j.Driver.Tests.BenchkitBackend/Implementations/SessionRunWorkloadExecutor.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Copyright (c) "Neo4j"
22
// Neo4j Sweden AB [https://neo4j.com]
3-
//
3+
//
44
// Licensed under the Apache License, Version 2.0 (the "License").
55
// You may not use this file except in compliance with the License.
66
// You may obtain a copy of the License at
7-
//
7+
//
88
// http://www.apache.org/licenses/LICENSE-2.0
9-
//
9+
//
1010
// Unless required by applicable law or agreed to in writing, software
1111
// distributed under the License is distributed on an "AS IS" BASIS,
1212
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,10 +21,10 @@ namespace Neo4j.Driver.Tests.BenchkitBackend.Implementations;
2121
using ILogger = Microsoft.Extensions.Logging.ILogger;
2222

2323
internal class SessionRunWorkloadExecutor(
24-
IDriver driver,
25-
IRecordConsumer recordConsumer,
26-
IWorkloadSessionBuilder sessionBuilder,
27-
ILogger logger)
24+
IDriver driver,
25+
IRecordConsumer recordConsumer,
26+
IWorkloadSessionBuilder sessionBuilder,
27+
ILogger logger)
2828
: IWorkloadExecutor
2929
{
3030
public async Task ExecuteWorkloadAsync(Workload workload)
@@ -47,17 +47,18 @@ private async Task ExecuteInParallelSessionsAsync(Workload workload)
4747
{
4848
var queryToRun = new Query(query.Text, query.Parameters);
4949
logger.LogDebug("Starting query {Query} in parallel session", queryToRun.Text);
50-
tasks.Add(Task.Run(
51-
async () =>
52-
{
53-
// create a new session in parallel for each query
54-
await using var session = sessionBuilder.BuildSession(driver, workload);
55-
56-
var resultCursor = await session.RunAsync(queryToRun);
57-
var records = await resultCursor.ToListAsync();
58-
logger.LogDebug("Received {RecordCount} records", records.Count);
59-
recordConsumer.ConsumeRecords(records);
60-
}));
50+
tasks.Add(
51+
Task.Run(
52+
async () =>
53+
{
54+
// create a new session in parallel for each query
55+
await using var session = sessionBuilder.BuildSession(driver, workload);
56+
57+
var resultCursor = await session.RunAsync(queryToRun);
58+
var records = await resultCursor.ToListAsync();
59+
logger.LogDebug("Received {RecordCount} records", records.Count);
60+
recordConsumer.ConsumeRecords(records);
61+
}));
6162
}
6263

6364
logger.LogDebug("Waiting for {TaskCount} parallel tasks to complete", tasks.Count);

0 commit comments

Comments
 (0)