[][src]Struct lambda_runtime_client::RuntimeClient

pub struct RuntimeClient { /* fields omitted */ }

Used by the Runtime to communicate with the internal endpoint.

Methods

impl<'ev> RuntimeClient[src]

pub fn new(
    host: &str,
    agent: Option<String>,
    runtime: Option<Runtime>
) -> Result<Self, ApiError>
[src]

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.

impl<'ev> RuntimeClient[src]

pub fn next_event(&self) -> Result<(Vec<u8>, EventContext), ApiError>[src]

Polls for new events to the Runtime APIs.

pub fn event_response(
    &self,
    request_id: &str,
    output: &[u8]
) -> Result<(), ApiError>
[src]

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_id The request id associated with the event we are serving the response for. This is returned as a header from the poll (/next) API.
  • output The 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.

pub fn event_error(
    &self,
    request_id: &str,
    e: &ErrorResponse
) -> Result<(), ApiError>
[src]

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_id The request id associated with the event we are serving the error for.
  • e An instance of errors::HandlerError generated by the handler function.

Returns

A Result object containing a bool return value for the call or an error::ApiError instance.

pub fn fail_init(&self, e: &ErrorResponse)[src]

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

  • e An instance of errors::RuntimeError.

Panics

If it cannot send the init error. In this case we panic to force the runtime to restart.

pub fn get_endpoint(&self) -> &str[src]

Returns the endpoint configured for this HTTP Runtime client.

Auto Trait Implementations

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Erased for T