Skip to content

Commit 628006c

Browse files
author
David Barsky
committed
cleaned up lifetimes.
1 parent ae92c6b commit 628006c

File tree

7 files changed

+23
-27
lines changed

7 files changed

+23
-27
lines changed

.rustfmt.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
reorder_imports = true
21
merge_imports = true
32
max_width = 120

lambda-runtime-client/src/client.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -308,18 +308,21 @@ impl RuntimeClient {
308308
pub fn fail_init(&self, e: &RuntimeApiError) {
309309
let uri: Uri = format!("http://{}/{}/runtime/init/error", self.endpoint, RUNTIME_API_VERSION)
310310
.parse()
311-
.expect("Could not generate Runtime API URI");
311+
.expect("Could not generate Runtime URI");
312312
error!("Calling fail_init Runtime API: {}", e.to_response().error_message);
313313
let err_body = serde_json::to_vec(&e.to_response()).expect("Could not serialize error object");
314314
let req = self.get_runtime_post_request(&uri, err_body);
315315

316-
match self.http_client.request(req).wait() {
317-
Ok(_) => {}
318-
Err(e) => {
316+
let resp = self
317+
.http_client
318+
.request(req)
319+
.map_err(|e| {
319320
error!("Error while sending init failed message: {}", e);
320321
panic!("Error while sending init failed message: {}", e);
321-
}
322-
}
322+
}).map(|resp| {
323+
info!("Successfully sent error response to the runtime API: {:?}", resp);
324+
});
325+
tokio::spawn(resp);
323326
}
324327

325328
/// Returns the endpoint configured for this HTTP Runtime client.

lambda-runtime/examples/basic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
extern crate lambda_runtime as lambda;
2-
extern crate serde_derive;
32
extern crate log;
3+
extern crate serde_derive;
44
extern crate simple_logger;
55

6-
use serde_derive::{Serialize, Deserialize};
7-
use lambda::{lambda, error::HandlerError};
6+
use lambda::{error::HandlerError, lambda};
87
use log::error;
8+
use serde_derive::{Deserialize, Serialize};
99
use std::error::Error;
1010

1111
#[derive(Deserialize)]

lambda-runtime/examples/with_custom_runtime.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
extern crate lambda_runtime as lambda;
2-
extern crate serde_derive;
32
extern crate log;
3+
extern crate serde_derive;
44
extern crate simple_logger;
55
extern crate tokio;
66

7-
use lambda::{lambda, error::HandlerError};
8-
use tokio::runtime::Runtime;
9-
use serde_derive::{Serialize, Deserialize};
7+
use lambda::{error::HandlerError, lambda};
108
use log::error;
9+
use serde_derive::{Deserialize, Serialize};
1110
use std::error::Error;
11+
use tokio::runtime::Runtime;
1212

1313
#[derive(Deserialize, Clone)]
1414
struct CustomEvent {

lambda-runtime/src/env.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct EnvConfigProvider;
4141

4242
impl EnvConfigProvider {
4343
pub fn new() -> Self {
44-
EnvConfigProvider { }
44+
EnvConfigProvider {}
4545
}
4646
}
4747

lambda-runtime/src/runtime.rs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ use std::{error::Error, result};
33
use serde;
44
use serde_json;
55

6-
use lambda_runtime_client::RuntimeClient;
76
use context::Context;
87
use env::{ConfigProvider, EnvConfigProvider, FunctionSettings};
98
use error::{HandlerError, RuntimeError};
9+
use lambda_runtime_client::RuntimeClient;
1010
use tokio::runtime::Runtime as TokioRuntime;
1111

1212
const MAX_RETRIES: i8 = 3;
@@ -53,11 +53,8 @@ macro_rules! lambda {
5353
/// The function panics if the `ConfigProvider` returns an error from the `get_runtime_api_endpoint()`
5454
/// or `get_function_settings()` methods. The panic forces AWS Lambda to terminate the environment
5555
/// and spin up a new one for the next invocation.
56-
pub(crate) fn start_with_config<E, O, C>(
57-
f: Handler<E, O>,
58-
config: C,
59-
runtime: Option<TokioRuntime>,
60-
) where
56+
pub(crate) fn start_with_config<E, O, C>(f: Handler<E, O>, config: C, runtime: Option<TokioRuntime>)
57+
where
6158
for<'invocation> E: serde::Deserialize<'invocation>,
6259
O: serde::Serialize,
6360
C: ConfigProvider,
@@ -103,11 +100,8 @@ pub(crate) fn start_with_config<E, O, C>(
103100
///
104101
/// # Panics
105102
/// The function panics if we cannot instantiate a new `RustRuntime` object.
106-
pub(crate) fn start_with_runtime_client<E, O>(
107-
f: Handler<E, O>,
108-
func_settings: FunctionSettings,
109-
client: RuntimeClient,
110-
) where
103+
pub(crate) fn start_with_runtime_client<E, O>(f: Handler<E, O>, func_settings: FunctionSettings, client: RuntimeClient)
104+
where
111105
for<'invocation> E: serde::Deserialize<'invocation>,
112106
O: serde::Serialize,
113107
{

lambda-runtime/tests/skeptic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
include!(concat!(env!("OUT_DIR"), "/skeptic-tests.rs"));
1+
include!(concat!(env!("OUT_DIR"), "/skeptic-tests.rs"));

0 commit comments

Comments
 (0)