Skip to content

Restore Session.reset as a private API #1390

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ public Set<Bookmark> lastBookmarks() {
return session.lastBookmarks();
}

// Private API
public void reset() {
Futures.blockingGet(
session.resetAsync(),
() -> terminateConnectionOnThreadInterrupt("Thread interrupted while resetting the session"));
}

private <T> T transaction(
AccessMode mode, @SuppressWarnings("deprecation") TransactionWork<T> work, TransactionConfig config) {
// use different code path compared to async so that work is executed in the caller thread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,24 @@ public CompletionStage<UnmanagedTransaction> beginTransactionAsync(
return newTransactionStage;
}

// Private API
public CompletionStage<Void> resetAsync() {
return existingTransactionOrNull()
.thenAccept(tx -> {
if (tx != null) {
tx.markTerminated(null);
}
})
.thenCompose(ignore -> connectionStage)
.thenCompose(connection -> {
if (connection != null) {
// there exists an active connection, send a RESET message over it
return connection.reset();
}
return completedWithNull();
});
}

public RetryLogic retryLogic() {
return retryLogic;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.neo4j.driver.internal.reactive;

import static org.neo4j.driver.internal.reactive.RxUtils.createEmptyPublisher;

import java.util.Map;
import java.util.concurrent.CompletableFuture;
import org.neo4j.driver.AccessMode;
Expand Down Expand Up @@ -129,6 +131,10 @@ public Bookmark lastBookmark() {
return InternalBookmark.from(session.lastBookmarks());
}

public Publisher<Void> reset() {
return createEmptyPublisher(session::resetAsync);
}

@Override
public <T> Publisher<T> close() {
return doClose();
Expand Down
Loading