-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathILambdaResponseStream.cs
More file actions
40 lines (35 loc) · 1.59 KB
/
ILambdaResponseStream.cs
File metadata and controls
40 lines (35 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
#if NET8_0_OR_GREATER
using System;
using System.Threading;
using System.Threading.Tasks;
namespace Amazon.Lambda.Core.ResponseStreaming
{
/// <summary>
/// Interface for writing streaming responses in AWS Lambda functions.
/// Obtained by calling <see cref="LambdaResponseStreamFactory.CreateStream"/> within a handler.
/// </summary>
internal interface ILambdaResponseStream : IDisposable
{
/// <summary>
/// Asynchronously writes a portion of a byte array to the response stream.
/// </summary>
/// <param name="buffer">The byte array containing data to write.</param>
/// <param name="offset">The zero-based byte offset in buffer at which to begin copying bytes.</param>
/// <param name="count">The number of bytes to write.</param>
/// <param name="cancellationToken">Optional cancellation token.</param>
/// <returns>A task representing the asynchronous operation.</returns>
/// <exception cref="InvalidOperationException">Thrown if the stream is already completed or an error has been reported.</exception>
Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken = default);
/// <summary>
/// Gets the total number of bytes written to the stream so far.
/// </summary>
long BytesWritten { get; }
/// <summary>
/// Gets whether an error has been reported.
/// </summary>
bool HasError { get; }
}
}
#endif