pub struct RuntimeClient { /* private fields */ }Expand description
Used by the Runtime to communicate with the internal endpoint.
Implementations§
Source§impl<'ev> RuntimeClient
impl<'ev> RuntimeClient
Sourcepub fn new(
host: &str,
agent: Option<String>,
runtime: Option<Runtime>,
) -> Result<Self, ApiError>
pub fn new( host: &str, agent: Option<String>, runtime: Option<Runtime>, ) -> Result<Self, ApiError>
Creates a new instance of the Runtime APIclient SDK. The http client has timeouts disabled and
will always send a Connection: keep-alive header. Optionally, the runtime client can receive
a user agent string. This string is used to make requests to the runtime APIs and is used to
identify the runtime being used by the function. For example, the lambda_runtime_core crate
uses AWS_Lambda_Rust/0.1.0 (rustc/1.31.1-stable). The runtime client can also receive an
instance of Tokio Runtime to use.
Source§impl<'ev> RuntimeClient
impl<'ev> RuntimeClient
Sourcepub fn next_event(&self) -> Result<(Vec<u8>, EventContext), ApiError>
pub fn next_event(&self) -> Result<(Vec<u8>, EventContext), ApiError>
Polls for new events to the Runtime APIs.
Sourcepub fn event_response(
&self,
request_id: &str,
output: &[u8],
) -> Result<(), ApiError>
pub fn event_response( &self, request_id: &str, output: &[u8], ) -> Result<(), ApiError>
Calls the Lambda Runtime APIs to submit a response to an event. In this function we treat all errors from the API as an unrecoverable error. This is because the API returns 4xx errors for responses that are too long. In that case, we simply log the output and fail.
§Arguments
request_idThe request id associated with the event we are serving the response for. This is returned as a header from the poll (/next) API.outputThe object be sent back to the Runtime APIs as a response.
§Returns
A Result object containing a bool return value for the call or an error::ApiError instance.
Sourcepub fn event_error(
&self,
request_id: &str,
e: &ErrorResponse,
) -> Result<(), ApiError>
pub fn event_error( &self, request_id: &str, e: &ErrorResponse, ) -> Result<(), ApiError>
Calls Lambda’s Runtime APIs to send an error generated by the Handler. Because it’s rust,
the error type for lambda is always handled.
§Arguments
request_idThe request id associated with the event we are serving the error for.eAn instance oferrors::HandlerErrorgenerated by the handler function.
§Returns
A Result object containing a bool return value for the call or an error::ApiError instance.
Sourcepub fn fail_init(&self, e: &ErrorResponse)
pub fn fail_init(&self, e: &ErrorResponse)
Calls the Runtime APIs to report a failure during the init process.
The contents of the error (e) parmeter are passed to the Runtime APIs
using the private to_response() method.
§Arguments
eAn instance oferrors::RuntimeError.
§Panics
If it cannot send the init error. In this case we panic to force the runtime to restart.
Sourcepub fn get_endpoint(&self) -> &str
pub fn get_endpoint(&self) -> &str
Returns the endpoint configured for this HTTP Runtime client.
Auto Trait Implementations§
impl !Freeze for RuntimeClient
impl !RefUnwindSafe for RuntimeClient
impl Send for RuntimeClient
impl Sync for RuntimeClient
impl Unpin for RuntimeClient
impl !UnwindSafe for RuntimeClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more