/*
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Amazon.Lambda.RuntimeSupport
{
///
/// Client to call the AWS Lambda Runtime API.
///
public interface IRuntimeApiClient
{
///
/// Report an initialization error as an asynchronous operation.
///
/// The exception to report.
/// The optional cancellation token to use.
/// A Task representing the asynchronous operation.
Task ReportInitializationErrorAsync(Exception exception, CancellationToken cancellationToken = default);
///
/// Send an initialization error with a type string but no other information as an asynchronous operation.
/// This can be used to directly control flow in Step Functions without creating an Exception class and throwing it.
///
/// The type of the error to report to Lambda. This does not need to be a .NET type name.
/// The optional cancellation token to use.
/// A Task representing the asynchronous operation.
Task ReportInitializationErrorAsync(string errorType, CancellationToken cancellationToken = default);
///
/// Get the next function invocation from the Runtime API as an asynchronous operation.
/// Completes when the next invocation is received.
///
/// The optional cancellation token to use to stop listening for the next invocation.
/// A Task representing the asynchronous operation.
Task GetNextInvocationAsync(CancellationToken cancellationToken = default);
///
/// Report an invocation error as an asynchronous operation.
///
/// The ID of the function request that caused the error.
/// The exception to report.
/// The optional cancellation token to use.
/// A Task representing the asynchronous operation.
Task ReportInvocationErrorAsync(string awsRequestId, Exception exception, CancellationToken cancellationToken = default);
///
/// Send a response to a function invocation to the Runtime API as an asynchronous operation.
///
/// The ID of the function request being responded to.
/// The content of the response to the function invocation.
/// The optional cancellation token to use.
///
Task SendResponseAsync(string awsRequestId, Stream outputStream, CancellationToken cancellationToken = default);
}
}