-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce notification configuration, severity and category #1396
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
injectives
force-pushed
the
feature/notifications
branch
11 times, most recently
from
March 27, 2023 23:28
064c3c5
to
e4343ba
Compare
injectives
changed the title
Feature/notifications
Introduce notification configuration, severity and category
Mar 27, 2023
injectives
force-pushed
the
feature/notifications
branch
8 times, most recently
from
March 28, 2023 00:12
43630ea
to
d0d778e
Compare
injectives
force-pushed
the
feature/notifications
branch
from
March 28, 2023 10:18
d0d778e
to
4d6fd03
Compare
bigmontz
reviewed
Mar 28, 2023
driver/src/main/java/org/neo4j/driver/internal/messaging/v3/BoltProtocolV3.java
Outdated
Show resolved
Hide resolved
Improve and expand the existing notification API. A new `NotificationSeverity` type represents a notification severity level. It includes 2 public constants: - `INFORMATION` - `WARNING` A new `NotificationCategory` type represents a notification category. It includes 6 public constants: - `HINT` - `UNRECOGNIZED` - `UNSUPPORTED` - `PERFORMANCE` - `DEPRECATION` - `GENERIC` The `Notification` class has been extended with the following 4 methods: - `Optional<NotificationSeverity> severityLevel()` - `Optional<String> rawSeverityLevel()` - `Optional<NotificationCategory> category()` - `Optional<String> rawCategory()` The `raw` methods return a `String` representation returned by the server. In case of an unrecognised value, both `severityLevel()` and `category()` methods return an empty `Optional`. This may happen if a new value is introduced in a future server version and a previous driver version does not support it. Additionally, an empty `Optional` may be returned when driver communicates with a server version that does not supply these values. The `severity()` method has been deprecated in favour of the `rawSeverityLevel()` method. A new `NotificationConfig` 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 and above. Both the `Config` and the `SessionConfig` support this new configuration. Sample usage: ```java // sets minimum notification severity level to WARNING // and explicitly disables both GENERIC and HINT notification categories var driverConfig = Config.builder() .withNotificationConfig(NotificationConfig.defaultConfig().enableMinimumSeverity(NotificationSeverity.WARNING).disableCategories(Set.of(NotificationCategory.GENERIC, NotificationCategory.HINT))) .build(); // disables all notifications var sessionConfig = SessionConfig.builder() .withNotificationConfig(NotificationConfig.disableAll()) .build(); ``` 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.
injectives
force-pushed
the
feature/notifications
branch
4 times, most recently
from
March 28, 2023 20:13
a1d61cc
to
4f7519e
Compare
This update introduces a new `UnsupportedFeatureException`. An instance of this exception will be emitted if a custom `NotificationConfig` is used and the driver comes across a Bolt connection that does not support the notification configuration.
injectives
force-pushed
the
feature/notifications
branch
from
March 29, 2023 08:43
4f7519e
to
aee68cf
Compare
bigmontz
approved these changes
Mar 29, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔔
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Objective
Improve and expand the existing notification API.
NotificationSeverity
A new
NotificationSeverity
type represents a notification severity level.It includes 2 public constants:
INFORMATION
WARNING
NotificationCategory
A new
NotificationCategory
type represents a notification category.It includes 6 public constants:
HINT
UNRECOGNIZED
UNSUPPORTED
PERFORMANCE
DEPRECATION
GENERIC
Notification
The
Notification
class has been extended with the following 4 methods:Optional<NotificationSeverity> severityLevel()
Optional<String> rawSeverityLevel()
Optional<NotificationCategory> category()
Optional<String> rawCategory()
The
raw
methods return aString
representation returned by the server. In case of an unrecognised value, bothseverityLevel()
andcategory()
methods return an emptyOptional
. This may happen if a new value is introduced in a future server version and a previous driver version does not support it. Additionally, an emptyOptional
may be returned when driver communicates with a server version that does not supply these values.The
severity()
method has been deprecated in favour of therawSeverityLevel()
method.NotificationConfig
A new
NotificationConfig
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 and above.Both the
Config
and theSessionConfig
support this new configuration.Sample usage:
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.