-
Notifications
You must be signed in to change notification settings - Fork 155
Introduce notification configuration, severity and category #1396
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
73 changes: 73 additions & 0 deletions
73
driver/src/main/java/org/neo4j/driver/NotificationCategory.java
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.neo4j.driver; | ||
|
||
import java.io.Serializable; | ||
import org.neo4j.driver.internal.InternalNotificationCategory; | ||
import org.neo4j.driver.internal.InternalNotificationCategory.Type; | ||
|
||
/** | ||
* Notification category. | ||
* | ||
* @since 5.7 | ||
*/ | ||
public sealed interface NotificationCategory extends Serializable permits InternalNotificationCategory { | ||
/** | ||
* A hint category. | ||
* <p> | ||
* For instance, the given hint cannot be satisfied. | ||
*/ | ||
NotificationCategory HINT = new InternalNotificationCategory(Type.HINT); | ||
|
||
/** | ||
* An unrecognized category. | ||
* <p> | ||
* For instance, the query or command mentions entities that are unknown to the system. | ||
*/ | ||
NotificationCategory UNRECOGNIZED = new InternalNotificationCategory(Type.UNRECOGNIZED); | ||
|
||
/** | ||
* An unsupported category. | ||
* <p> | ||
* For instance, the query/command is trying to use features that are not supported by the current system or using | ||
* features that are experimental and should not be used in production. | ||
*/ | ||
NotificationCategory UNSUPPORTED = new InternalNotificationCategory(Type.UNSUPPORTED); | ||
|
||
/** | ||
* A performance category. | ||
* <p> | ||
* For instance, the query uses costly operations and might be slow. | ||
*/ | ||
NotificationCategory PERFORMANCE = new InternalNotificationCategory(Type.PERFORMANCE); | ||
|
||
/** | ||
* A deprecation category. | ||
* <p> | ||
* For instance, the query/command use deprecated features that should be replaced. | ||
*/ | ||
NotificationCategory DEPRECATION = new InternalNotificationCategory(Type.DEPRECATION); | ||
|
||
/** | ||
* A generic category. | ||
* <p> | ||
* For instance, notifications that are not part of a more specific class. | ||
*/ | ||
NotificationCategory GENERIC = new InternalNotificationCategory(Type.GENERIC); | ||
} |
81 changes: 81 additions & 0 deletions
81
driver/src/main/java/org/neo4j/driver/NotificationConfig.java
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.neo4j.driver; | ||
|
||
import java.io.Serializable; | ||
import java.util.Set; | ||
import org.neo4j.driver.internal.InternalNotificationConfig; | ||
import org.neo4j.driver.internal.InternalNotificationSeverity; | ||
import org.neo4j.driver.summary.ResultSummary; | ||
|
||
/** | ||
* A notification configuration defining what notifications should be supplied by the server. | ||
* <p> | ||
* There are currently 2 optional settings that may be activated: | ||
* <ul> | ||
* <li>Minimum notification severity - sets a baseline severity for notifications, similar to the logging levels.</li> | ||
* <li>A set of disabled notification categories - explicitly disables a set of notification categories.</li> | ||
* </ul> | ||
* <p> | ||
* By default, both options are not activated. | ||
* | ||
* @since 5.7 | ||
* @see ResultSummary#notifications() | ||
* @see org.neo4j.driver.summary.Notification | ||
*/ | ||
public sealed interface NotificationConfig extends Serializable permits InternalNotificationConfig { | ||
/** | ||
* Returns a default notification configuration. | ||
* <p> | ||
* The default configuration has no settings activated, meaning the resulting behaviour depends on an upstream | ||
* context. For instance, when this config is set on the session level, the resulting behaviour depends on the | ||
* driver's config. Likewise, when this config is set on the driver level, the resulting behaviour depends on the | ||
* server. | ||
* | ||
* @return the default config | ||
*/ | ||
static NotificationConfig defaultConfig() { | ||
return new InternalNotificationConfig(null, null); | ||
} | ||
|
||
/** | ||
* A config that disables all notifications. | ||
* | ||
* @return the config that disables all notifications | ||
*/ | ||
static NotificationConfig disableAllConfig() { | ||
return new InternalNotificationConfig(InternalNotificationSeverity.OFF, null); | ||
} | ||
|
||
/** | ||
* Returns a config that sets a minimum severity level for notifications. | ||
* | ||
* @param minimumSeverity the minimum severity level | ||
* @return the config | ||
*/ | ||
NotificationConfig enableMinimumSeverity(NotificationSeverity minimumSeverity); | ||
|
||
/** | ||
* Returns a config that disables a set of notification categories. | ||
* | ||
* @param disabledCategories the categories to disable, an empty set means no categories are disabled | ||
* @return the config | ||
*/ | ||
NotificationConfig disableCategories(Set<NotificationCategory> disabledCategories); | ||
} |
41 changes: 41 additions & 0 deletions
41
driver/src/main/java/org/neo4j/driver/NotificationSeverity.java
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) "Neo4j" | ||
* Neo4j Sweden AB [http://neo4j.com] | ||
* | ||
* This file is part of Neo4j. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.neo4j.driver; | ||
|
||
import static org.neo4j.driver.internal.InternalNotificationSeverity.Type; | ||
|
||
import java.io.Serializable; | ||
import org.neo4j.driver.internal.InternalNotificationSeverity; | ||
|
||
/** | ||
* Notification severity level. | ||
* | ||
* @since 5.7 | ||
*/ | ||
public sealed interface NotificationSeverity extends Serializable, Comparable<NotificationSeverity> | ||
permits InternalNotificationSeverity { | ||
/** | ||
* An information severity level. | ||
*/ | ||
NotificationSeverity INFORMATION = new InternalNotificationSeverity(Type.INFORMATION, 800); | ||
/** | ||
* A warning severity level. | ||
*/ | ||
NotificationSeverity WARNING = new InternalNotificationSeverity(Type.WARNING, 900); | ||
} |
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.