Skip to content

Commit

Permalink
Extend IODataOutputInStreamErrorListener interface to support asynchr…
Browse files Browse the repository at this point in the history
…onous notifications when an in-stream error is to be written
  • Loading branch information
John Gathogo committed Apr 30, 2021
1 parent 2dd24f1 commit c2db8d4
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Microsoft.OData.Core/Batch/ODataBatchWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,14 @@ public Task FlushAsync()
/// </remarks>
public abstract void OnInStreamError();

/// <inheritdoc/>
public virtual Task OnInStreamErrorAsync()
{
// NOTE: ODataBatchWriter class is abstract and public. This method body is intended
// to prevent a breaking change in subclasses that provide the implementation.
throw new NotImplementedException();
}

/// <summary>
/// Flush the output.
/// </summary>
Expand Down
14 changes: 14 additions & 0 deletions src/Microsoft.OData.Core/IODataOutputInStreamErrorListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

namespace Microsoft.OData
{
#region Namespaces
using System.Threading.Tasks;
#endregion Namespaces

/// <summary>
/// An interface that allows the implementations of the writers to get notified if an in-stream error is to be written.
/// </summary>
Expand All @@ -19,5 +23,15 @@ internal interface IODataOutputInStreamErrorListener
/// If the listener returns, the writer should not allow any more writing, since the in-stream error is the last thing in the payload.
/// </remarks>
void OnInStreamError();

/// <summary>
/// This method asynchronously notifies the listener, that an in-stream error is to be written.
/// </summary>
/// <remarks>
/// This listener can choose to fail, if the currently written payload doesn't support in-stream error at this position.
/// If the listener returns, the writer should not allow any more writing, since the in-stream error is the last thing in the payload.
/// </remarks>
/// <returns>A task that represents the asynchronous operation.</returns>
Task OnInStreamErrorAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,12 @@ void IODataOutputInStreamErrorListener.OnInStreamError()
this.inStreamErrorListener.OnInStreamError();
}

/// <inheritdoc/>
Task IODataOutputInStreamErrorListener.OnInStreamErrorAsync()
{
throw new NotImplementedException();
}

#endregion
}
}
6 changes: 6 additions & 0 deletions src/Microsoft.OData.Core/ODataAsynchronousWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,12 @@ void IODataOutputInStreamErrorListener.OnInStreamError()
throw new ODataException(Strings.ODataAsyncWriter_CannotWriteInStreamErrorForAsync);
}

/// <inheritdoc/>
Task IODataOutputInStreamErrorListener.OnInStreamErrorAsync()
{
throw new NotImplementedException();
}

/// <summary>
/// Validates that the async writer is not disposed.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Microsoft.OData.Core/ODataCollectionWriterCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ void IODataOutputInStreamErrorListener.OnInStreamError()
this.EnterScope(CollectionWriterState.Error, this.scopes.Peek().Item);
}

/// <inheritdoc/>
Task IODataOutputInStreamErrorListener.OnInStreamErrorAsync()
{
throw new NotImplementedException();
}

/// <summary>
/// Determines whether a given writer state is considered an error state.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions src/Microsoft.OData.Core/ODataParameterWriterCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ void IODataOutputInStreamErrorListener.OnInStreamError()
throw new ODataException(Strings.ODataParameterWriter_InStreamErrorNotSupported);
}

/// <inheritdoc/>
Task IODataOutputInStreamErrorListener.OnInStreamErrorAsync()
{
throw new NotImplementedException();
}

/// <summary>
/// Check if the object has been disposed; called from all public API methods. Throws an ObjectDisposedException if the object
/// has already been disposed.
Expand Down
6 changes: 6 additions & 0 deletions src/Microsoft.OData.Core/ODataWriterCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,12 @@ void IODataOutputInStreamErrorListener.OnInStreamError()
this.EnterScope(WriterState.Error, this.CurrentScope.Item);
}

/// <inheritdoc/>
Task IODataOutputInStreamErrorListener.OnInStreamErrorAsync()
{
throw new NotImplementedException();
}

/// <summary>
/// This method is called when a stream is requested. It is a no-op.
/// </summary>
Expand Down

0 comments on commit c2db8d4

Please sign in to comment.