Skip to content

5.7.0

Compare
Choose a tag to compare
@RichardIrons-neo4j RichardIrons-neo4j released this 31 Mar 15:17
· 96 commits to 5.0 since this release
2de28b4

🔬 Experimental/Preview changes

  • the Neo4j.Driver.Experimental namespace has been renamed to Neo4j.Driver.Preview. This will be a compile-time breaking change for any code using this namespace. No functionality has been changed.

⭐ New Features

⭐ Notifications Updates #691

Introduce better notifications, and configuration(Docs).

NotificationSeverity

Introduce NotificationSeverity enum represents to represent a notification's severity level.

Severities:

  • Warning
  • Information
  • Unknown

5.7 API Doc

NotificationCategory

Introduce NotificationCategory enum represents to represent a notification's category.

Categories:

  • Hint
  • Unrecognized
  • Unsupported
  • Performance
  • Deprecation
  • Generic
  • Unknown

5.7 API Doc

Notification

The INotification interface extended with 4 new properties:

  • NotificationSeverity SeverityLevel
  • string RawSeverityLevel
  • NotificationCategory Category
  • string RawCategory

The Raw prefixed properties return an unparsed string representation returned by the server.
In case of an unrecognised values, both SeverityLevel and Category will be Unknown.
This may happen if a new value is introduced in a future server version and a previous driver version does not support it.
Additionally, Unknown may be returned when driver communicates with a server version that does not supply these values.

Deprecation ⚠️

The Severity property has been deprecated in favour of the RawSeverityLevel property.

5.7 API Doc

NotificationConfig

Introduce INotificationConfig type has been introduced to allow notification preferences management.
By default, the server determines what notifications are provided to the driver.
However, user can set a minimum severity level and/or a set of disabled notification categories to manage its expectations.
This feature is only supported on Bolt protocol version 5.2(Introduced in server 5.7) and above.

Both the Config and the SessionConfig support this new configuration, configured with builders:

Introduce Severity(API Docs) & Category(API Docs) enums for configuration.

Notification Configuration Hierarchy

Servers will assess which notifications to emit based on a hierarchy, using the most recently declared values.

using var driver = GraphDatabase.Driver(Neo4jUrl, AuthToken, cb => cb.WithNotificationsDisabled());
using var session = driver.AsyncSession();
...
var summary = await cursor.ConsumeAsync();
// No notifications should be emitted.
// This is useful for helping the server optimize operations as the server doesn't need to assess for any notifications.
// Notifications are not sent over the wire too meaning less data! 
Debug.Assert(summary.Notifications.Count() == 0); 

Severity configuration sets the minimum level of a notification, while category confugration is used to disable a category.

using var driver = GraphDatabase.Driver(Neo4jUrl, AuthToken, cb => cb.WithNotifications(Severity.Warning, null));
using var session = driver.AsyncSession(scb => scb.WithNotifications(null, new []{Category.Performance}));
...
var summary = await cursor.ConsumeAsync();
// no Information or performance notifications emitted.
Debug.Assert(summary.Notifications.Count(x => 
        x.NotificationCategory == NotificationCategory.Performance ||
        x.NotificationSeverity == NotificationSeverity.Information) == 0); 

if you require to enable a previously disabled categories for a session you can emit it from disabledCategories parameter.

using var driver = GraphDatabase.Driver(Neo4jUrl, AuthToken, cb => cb.WithNotifications(null, new []{Category.Performance}));
using var session = driver.AsyncSession(scb => scb.WithNotifications(null, new Category[]{}));
...
var summary = await cursor.ConsumeAsync();
// Notifications can contain anything again!

Bolt

This update includes support for both 5.1 and 5.2 versions. The latter is required for the full support of the new notification updates.