Skip to content

Commit a350d92

Browse files
committed
Initial
1 parent e2962b8 commit a350d92

File tree

75 files changed

+2329
-263
lines changed

Some content is hidden

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

75 files changed

+2329
-263
lines changed

driver/clirr-ignored-differences.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,4 +433,28 @@
433433
<method>org.neo4j.driver.BookmarkManager queryTaskBookmarkManager()</method>
434434
</difference>
435435

436+
<difference>
437+
<className>org/neo4j/driver/summary/Notification</className>
438+
<differenceType>7012</differenceType>
439+
<method>java.util.Optional severityLevel()</method>
440+
</difference>
441+
442+
<difference>
443+
<className>org/neo4j/driver/summary/Notification</className>
444+
<differenceType>7012</differenceType>
445+
<method>java.util.Optional rawSeverityLevel()</method>
446+
</difference>
447+
448+
<difference>
449+
<className>org/neo4j/driver/summary/Notification</className>
450+
<differenceType>7012</differenceType>
451+
<method>java.util.Optional category()</method>
452+
</difference>
453+
454+
<difference>
455+
<className>org/neo4j/driver/summary/Notification</className>
456+
<differenceType>7012</differenceType>
457+
<method>java.util.Optional rawCategory()</method>
458+
</difference>
459+
436460
</differences>

driver/src/main/java/org/neo4j/driver/Config.java

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import java.util.Collections;
3131
import java.util.List;
3232
import java.util.Objects;
33+
import java.util.Optional;
34+
import java.util.Set;
3335
import java.util.concurrent.TimeUnit;
3436
import java.util.logging.Level;
3537
import org.neo4j.driver.internal.SecuritySettings;
@@ -143,6 +145,14 @@ public final class Config implements Serializable {
143145
* The user_agent configured for this driver.
144146
*/
145147
private final String userAgent;
148+
/**
149+
* The minimum notification severity level.
150+
*/
151+
private NotificationSeveritySetting minNotificationSeverity;
152+
/**
153+
* The disabled notification categories.
154+
*/
155+
private Set<NotificationCategorySetting> disabledNotificationCategories;
146156
/**
147157
* The {@link MetricsAdapter}.
148158
*/
@@ -166,6 +176,8 @@ private Config(ConfigBuilder builder) {
166176
this.maxTransactionRetryTimeMillis = builder.maxTransactionRetryTimeMillis;
167177
this.resolver = builder.resolver;
168178
this.fetchSize = builder.fetchSize;
179+
this.minNotificationSeverity = builder.minNotificationSeverity;
180+
this.disabledNotificationCategories = builder.disabledNotificationCategories;
169181

170182
this.eventLoopThreads = builder.eventLoopThreads;
171183
this.metricsAdapter = builder.metricsAdapter;
@@ -311,6 +323,26 @@ public long fetchSize() {
311323
return fetchSize;
312324
}
313325

326+
/**
327+
* Returns minimum notification severity level.
328+
*
329+
* @return the minimum notification severity level
330+
* @since 5.7
331+
*/
332+
public NotificationSeveritySetting notificationsMinimumSeverityLevelSeverity() {
333+
return minNotificationSeverity;
334+
}
335+
336+
/**
337+
* Returns disabled notification categories.
338+
*
339+
* @return the disabled notification categories
340+
* @since 5.7
341+
*/
342+
public Optional<DisabledNotificationCategories> notificationsDisabledCategories() {
343+
return Optional.ofNullable(disabledNotificationCategories).map(DisabledNotificationCategories::new);
344+
}
345+
314346
/**
315347
* Returns the number of {@link io.netty.channel.EventLoop} threads.
316348
* @return the number of threads
@@ -362,6 +394,8 @@ public static final class ConfigBuilder {
362394
private ServerAddressResolver resolver;
363395
private MetricsAdapter metricsAdapter = MetricsAdapter.DEV_NULL;
364396
private long fetchSize = FetchSizeUtil.DEFAULT_FETCH_SIZE;
397+
private NotificationSeveritySetting minNotificationSeverity = NotificationSeveritySetting.INHERIT;
398+
private Set<NotificationCategorySetting> disabledNotificationCategories = null;
365399
private int eventLoopThreads = 0;
366400

367401
private ConfigBuilder() {}
@@ -757,6 +791,49 @@ public ConfigBuilder withUserAgent(String userAgent) {
757791
return this;
758792
}
759793

794+
/**
795+
* Sets minimum notification severity level that is used by the server when supplying the notifications.
796+
* <p>
797+
* By default, it is set to {@link NotificationSeveritySetting#INHERIT}.
798+
*
799+
* @param severity the minimum severity level
800+
* @return this builder
801+
* @see org.neo4j.driver.summary.Notification
802+
* @since 5.7
803+
*/
804+
public ConfigBuilder withMinimumNotificationSeverity(NotificationSeveritySetting severity) {
805+
this.minNotificationSeverity = Objects.requireNonNull(severity, "severity must not be null");
806+
return this;
807+
}
808+
809+
/**
810+
* Sets notification categories that will be disabled by the server when supplying the notifications.
811+
* <p>
812+
* By default, this has no explicit value. The server determines the behaviour.
813+
*
814+
* @param categories the set of disabled notification categories
815+
* @return this builder
816+
* @see org.neo4j.driver.summary.Notification
817+
* @since 5.7
818+
*/
819+
public ConfigBuilder withDisabledNotificationCategories(Set<NotificationCategorySetting> categories) {
820+
this.disabledNotificationCategories =
821+
Set.copyOf(Objects.requireNonNull(categories, "categories must not be null"));
822+
return this;
823+
}
824+
825+
/**
826+
* Unsets disabled notification categories.
827+
*
828+
* @return this builder
829+
* @see org.neo4j.driver.summary.Notification
830+
* @since 5.7
831+
*/
832+
public ConfigBuilder withInheritedDisabledNotificationCategories() {
833+
this.disabledNotificationCategories = null;
834+
return this;
835+
}
836+
760837
/**
761838
* Extracts the driver version from the driver jar MANIFEST.MF file.
762839
*/
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.driver;
20+
21+
import java.util.Set;
22+
23+
/**
24+
* Disabled notification categories.
25+
*
26+
* @param categories the disabled categories
27+
* @since 5.7
28+
*/
29+
public record DisabledNotificationCategories(Set<NotificationCategorySetting> categories) {}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.driver;
20+
21+
import org.neo4j.driver.summary.Notification;
22+
23+
/**
24+
* {@link Notification} categories that are used in {@link Config} and {@link SessionConfig}.
25+
*
26+
* @since 5.7
27+
*/
28+
public enum NotificationCategorySetting {
29+
/**
30+
* A hint category.
31+
* <p>
32+
* For instance, the given hint cannot be satisfied.
33+
*/
34+
HINT,
35+
/**
36+
* An unrecognized category.
37+
* <p>
38+
* For instance, the query or command mentions entities that are unknown to the system.
39+
*/
40+
UNRECOGNIZED,
41+
/**
42+
* An unsupported category.
43+
* <p>
44+
* For instance, the query/command is trying to use features that are not supported by the current system or using
45+
* features that are experimental and should not be used in production.
46+
*/
47+
UNSUPPORTED,
48+
/**
49+
* A performance category.
50+
* <p>
51+
* For instance, the query uses costly operations and might be slow.
52+
*/
53+
PERFORMANCE,
54+
/**
55+
* A deprecation category.
56+
* <p>
57+
* For instance, the query/command use deprecated features that should be replaced.
58+
*/
59+
DEPRECATION,
60+
/**
61+
* A generic category.
62+
* <p>
63+
* For instance, notifications that are not part of a more specific class.
64+
*/
65+
GENERIC
66+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
package org.neo4j.driver;
20+
21+
import org.neo4j.driver.summary.Notification;
22+
23+
/**
24+
* {@link Notification} severity levels that are used in {@link Config} and {@link SessionConfig}.
25+
*
26+
* @since 5.7
27+
*/
28+
public enum NotificationSeveritySetting {
29+
/**
30+
* A warning severity level.
31+
*/
32+
WARNING,
33+
/**
34+
* An information severity level.
35+
*/
36+
INFORMATION,
37+
/**
38+
* A special value indicating that severity level is inherited from an upstream configuration.
39+
* <p>
40+
* For instance, if this is set on the {@link org.neo4j.driver.SessionConfig}, then the value is inherited from the
41+
* driver's {@link org.neo4j.driver.Config}. Likewise, if this is set on the driver's
42+
* {@link org.neo4j.driver.Config}, then the value is effectively inherited from the server.
43+
*/
44+
INHERIT,
45+
/**
46+
* A special value that turns off all notifications.
47+
*/
48+
OFF
49+
}

0 commit comments

Comments
 (0)