Skip to content

Commit

Permalink
Deprecations (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
thelonelyvulpes authored Sep 8, 2022
1 parent ad2c0dc commit 5e54252
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Neo4j.Driver/Neo4j.Driver.Reactive/IRxSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public interface IRxSession : IRxRunnable
/// <param name="work">a unit of work to be executed</param>
/// <typeparam name="T">the return type of the unit of work</typeparam>
/// <returns>the reactive stream returned by the unit of work</returns>
[Obsolete("Deprecated, Replaced by ExecuteRead, will be removed in 6.0")]
IObservable<T> ReadTransaction<T>(Func<IRxTransaction, IObservable<T>> work);

/// <summary>
Expand All @@ -129,6 +130,7 @@ public interface IRxSession : IRxRunnable
/// defines how to create the configuration for the created transaction</param>
/// <typeparam name="T">the return type of the unit of work</typeparam>
/// <returns>the reactive stream returned by the unit of work</returns>
[Obsolete("Deprecated, Replaced by ExecuteRead, will be removed in 6.0")]
IObservable<T> ReadTransaction<T>(Func<IRxTransaction, IObservable<T>> work,
Action<TransactionConfigBuilder> action);

Expand All @@ -139,6 +141,7 @@ IObservable<T> ReadTransaction<T>(Func<IRxTransaction, IObservable<T>> work,
/// <param name="work">a unit of work to be executed</param>
/// <typeparam name="T">the return type of the unit of work</typeparam>
/// <returns>the reactive stream returned by the unit of work</returns>
[Obsolete("Deprecated, Replaced by ExecuteWrite, will be removed in 6.0")]
IObservable<T> WriteTransaction<T>(Func<IRxTransaction, IObservable<T>> work);

/// <summary>
Expand All @@ -151,9 +154,50 @@ IObservable<T> ReadTransaction<T>(Func<IRxTransaction, IObservable<T>> work,
/// defines how to create the configuration for the created transaction</param>
/// <typeparam name="T">the return type of the unit of work</typeparam>
/// <returns>the reactive stream returned by the unit of work</returns>
[Obsolete("Deprecated, Replaced by ExecuteWrite, will be removed in 6.0")]
IObservable<T> WriteTransaction<T>(Func<IRxTransaction, IObservable<T>> work,
Action<TransactionConfigBuilder> action);

/// <summary>
/// Execute the provided unit of work in a <see cref="AccessMode.Read"/> managed reactive transaction.
/// </summary>
/// <param name="work">a unit of work to be executed</param>
/// <typeparam name="T">the return type of the unit of work</typeparam>
/// <returns>the reactive stream returned by the unit of work</returns>
IObservable<T> ExecuteRead<T>(Func<IRxRunnable, IObservable<T>> work);

/// <summary>
/// Execute the provided unit of work in a <see cref="AccessMode.Read"/> managed reactive transaction which is created with the provided
/// <see cref="TransactionConfig"/>.
/// </summary>
/// <param name="work">a unit of work to be executed</param>
/// <param name="action">Given a <see cref="TransactionConfigBuilder"/>,
/// defines how to create the configuration for the created transaction</param>
/// <typeparam name="T">the return type of the unit of work</typeparam>
/// <returns>the reactive stream returned by the unit of work</returns>
IObservable<T> ExecuteRead<T>(Func<IRxRunnable, IObservable<T>> work,
Action<TransactionConfigBuilder> action);

/// <summary>
/// Execute the provided unit of work in a <see cref="AccessMode.Write"/> managed reactive transaction.
/// </summary>
/// <param name="work">a unit of work to be executed</param>
/// <typeparam name="T">the return type of the unit of work</typeparam>
/// <returns>the reactive stream returned by the unit of work</returns>
IObservable<T> ExecuteWrite<T>(Func<IRxRunnable, IObservable<T>> work);

/// <summary>
/// Execute the provided unit of work in a <see cref="AccessMode.Write"/> managed reactive transaction which is created with the provided
/// <see cref="TransactionConfig"/>.
/// </summary>
/// <param name="work">a unit of work to be executed</param>
/// <param name="action">Given a <see cref="TransactionConfigBuilder"/>,
/// defines how to create the configuration for the created transaction</param>
/// <typeparam name="T">the return type of the unit of work</typeparam>
/// <returns>the reactive stream returned by the unit of work</returns>
IObservable<T> ExecuteWrite<T>(Func<IRxRunnable, IObservable<T>> work,
Action<TransactionConfigBuilder> action);

/// <summary>
/// Closes this session and returns an empty reactive stream.
///
Expand Down
20 changes: 20 additions & 0 deletions Neo4j.Driver/Neo4j.Driver.Reactive/Internal/InternalRxSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,26 @@ public IObservable<T> WriteTransaction<T>(Func<IRxTransaction, IObservable<T>> w
return RunTransaction(AccessMode.Write, work, action);
}

public IObservable<T> ExecuteRead<T>(Func<IRxRunnable, IObservable<T>> work)
{
return ReadTransaction(work, null);
}

public IObservable<T> ExecuteRead<T>(Func<IRxRunnable, IObservable<T>> work, Action<TransactionConfigBuilder> action)
{
return RunTransaction(AccessMode.Read, work, action);
}

public IObservable<T> ExecuteWrite<T>(Func<IRxRunnable, IObservable<T>> work)
{
return WriteTransaction(work, null);
}

public IObservable<T> ExecuteWrite<T>(Func<IRxRunnable, IObservable<T>> work, Action<TransactionConfigBuilder> action)
{
return RunTransaction(AccessMode.Write, work, action);
}

internal IObservable<T> RunTransaction<T>(AccessMode mode,
Func<IRxTransaction, IObservable<T>> work,
Action<TransactionConfigBuilder> action)
Expand Down
40 changes: 40 additions & 0 deletions Neo4j.Driver/Neo4j.Driver.Simple/ISession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public interface ISession : IQueryRunner
/// <typeparam name="T">The return type of the given unit of work.</typeparam>
/// <param name="work">The <see cref="Func{TResult}"/> to be applied to a new read transaction.</param>
/// <returns>A result as returned by the given unit of work.</returns>
[Obsolete("Deprecated, Replaced by ExecuteRead, will be removed in 6.0")]
T ReadTransaction<T>(Func<ITransaction, T> work);

/// <summary>
Expand All @@ -91,6 +92,7 @@ public interface ISession : IQueryRunner
/// <param name="action">Given a <see cref="TransactionConfigBuilder"/>, defines how to set the configurations for the new transaction.
/// This configuration overrides server side default transaction configurations.</param>
/// <returns>A result as returned by the given unit of work.</returns>
[Obsolete("Deprecated, Replaced by ExecuteRead, will be removed in 6.0")]
T ReadTransaction<T>(Func<ITransaction, T> work, Action<TransactionConfigBuilder> action);

/// <summary>
Expand All @@ -99,6 +101,7 @@ public interface ISession : IQueryRunner
/// <typeparam name="T">The return type of the given unit of work.</typeparam>
/// <param name="work">The <see cref="Func{TResult}"/> to be applied to a new write transaction.</param>
/// <returns>A result as returned by the given unit of work.</returns>
[Obsolete("Deprecated, Replaced by ExecuteWrite, will be removed in 6.0")]
T WriteTransaction<T>(Func<ITransaction, T> work);

/// <summary>
Expand All @@ -109,8 +112,45 @@ public interface ISession : IQueryRunner
/// <param name="action">Given a <see cref="TransactionConfigBuilder"/>, defines how to set the configurations for the new transaction.
/// This configuration overrides server side default transaction configurations. See <see cref="TransactionConfig"/></param>
/// <returns>A result as returned by the given unit of work.</returns>
[Obsolete("Deprecated, Replaced by ExecuteWrite, will be removed in 6.0")]
T WriteTransaction<T>(Func<ITransaction, T> work, Action<TransactionConfigBuilder> action);

/// <summary>
/// Execute given unit of work in a <see cref="AccessMode.Read"/> managed transaction.
/// </summary>
/// <typeparam name="T">The return type of the given unit of work.</typeparam>
/// <param name="work">The <see cref="Func{TResult}"/> to be applied to a new read transaction.</param>
/// <returns>A result as returned by the given unit of work.</returns>
T ExecuteRead<T>(Func<IQueryRunner, T> work);

/// <summary>
/// Execute given unit of work in a <see cref="AccessMode.Read"/> managed transaction with a specific <see cref="TransactionConfig"/>.
/// </summary>
/// <typeparam name="T">The return type of the given unit of work.</typeparam>
/// <param name="work">The <see cref="Func{TResult}"/> to be applied to a new read transaction.</param>
/// <param name="action">Given a <see cref="TransactionConfigBuilder"/>, defines how to set the configurations for the new transaction.
/// This configuration overrides server side default transaction configurations.</param>
/// <returns>A result as returned by the given unit of work.</returns>
T ExecuteRead<T>(Func<IQueryRunner, T> work, Action<TransactionConfigBuilder> action);

/// <summary>
/// Execute given unit of work in a <see cref="AccessMode.Write"/> managed transaction.
/// </summary>
/// <typeparam name="T">The return type of the given unit of work.</typeparam>
/// <param name="work">The <see cref="Func{TResult}"/> to be applied to a new write transaction.</param>
/// <returns>A result as returned by the given unit of work.</returns>
T ExecuteWrite<T>(Func<IQueryRunner, T> work);

/// <summary>
/// Execute given unit of work in a <see cref="AccessMode.Write"/> managed transaction with a specific <see cref="TransactionConfig"/>.
/// </summary>
/// <typeparam name="T">The return type of the given unit of work.</typeparam>
/// <param name="work">The <see cref="Func{TResult}"/> to be applied to a new write transaction.</param>
/// <param name="action">Given a <see cref="TransactionConfigBuilder"/>, defines how to set the configurations for the new transaction.
/// This configuration overrides server side default transaction configurations. See <see cref="TransactionConfig"/></param>
/// <returns>A result as returned by the given unit of work.</returns>
T ExecuteWrite<T>(Func<IQueryRunner, T> work, Action<TransactionConfigBuilder> action);

/// <summary>
///
/// Run a query with the specific <see cref="TransactionConfig"/> and return a result stream.
Expand Down
21 changes: 21 additions & 0 deletions Neo4j.Driver/Neo4j.Driver.Simple/Internal/InternalSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,27 @@ public T WriteTransaction<T>(Func<ITransaction, T> work, Action<TransactionConfi
return RunTransaction(AccessMode.Write, work, action);
}

public T ExecuteRead<T>(Func<IQueryRunner, T> work)
{
return ReadTransaction(work, null);
}

public T ExecuteRead<T>(Func<IQueryRunner, T> work, Action<TransactionConfigBuilder> action)
{
return RunTransaction(AccessMode.Read, work, action);
}

public T ExecuteWrite<T>(Func<IQueryRunner, T> work)
{
return WriteTransaction(work, null);
}

public T ExecuteWrite<T>(Func<IQueryRunner, T> work, Action<TransactionConfigBuilder> action)
{
return RunTransaction(AccessMode.Write, work, action);
}


internal T RunTransaction<T>(AccessMode mode, Func<ITransaction, T> work, Action<TransactionConfigBuilder> action)
{
return _retryLogic.Retry(() =>
Expand Down

0 comments on commit 5e54252

Please sign in to comment.