11use std:: { error:: Error , result} ;
22
3- use lambda_runtime_client;
43use serde;
54use serde_json;
65
6+ use lambda_runtime_client:: RuntimeClient ;
77use context:: Context ;
88use env:: { ConfigProvider , EnvConfigProvider , FunctionSettings } ;
99use error:: { HandlerError , RuntimeError } ;
@@ -22,12 +22,12 @@ pub type Handler<E, O> = fn(E, Context) -> Result<O, HandlerError>;
2222///
2323/// # Panics
2424/// The function panics if the Lambda environment variables are not set.
25- pub fn start < E : ' static , O : ' static > ( f : Handler < E , O > , runtime : Option < TokioRuntime > )
25+ pub fn start < E , O > ( f : Handler < E , O > , runtime : Option < TokioRuntime > )
2626where
2727 for < ' invocation > E : serde:: Deserialize < ' invocation > ,
2828 O : serde:: Serialize ,
2929{
30- start_with_config ( f, & EnvConfigProvider { } , runtime)
30+ start_with_config ( f, EnvConfigProvider :: new ( ) , runtime)
3131}
3232
3333#[ macro_export]
@@ -53,13 +53,14 @@ 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 : ' static , O : ' static > (
56+ pub ( crate ) fn start_with_config < E , O , C > (
5757 f : Handler < E , O > ,
58- config : & ' static ConfigProvider ,
58+ config : C ,
5959 runtime : Option < TokioRuntime > ,
6060) where
6161 for < ' invocation > E : serde:: Deserialize < ' invocation > ,
6262 O : serde:: Serialize ,
63+ C : ConfigProvider ,
6364{
6465 // if we cannot find the endpoint we panic, nothing else we can do.
6566 let endpoint: String ;
@@ -81,10 +82,9 @@ pub(crate) fn start_with_config<E: 'static, O: 'static>(
8182 }
8283 }
8384
84- match lambda_runtime_client :: HttpRuntimeClient :: new ( endpoint, runtime) {
85+ match RuntimeClient :: new ( endpoint, runtime) {
8586 Ok ( client) => {
86- let trait_client: & lambda_runtime_client:: RuntimeClient = & client;
87- start_with_runtime_client ( f, function_config, trait_client) ;
87+ start_with_runtime_client ( f, function_config, client) ;
8888 }
8989 Err ( e) => {
9090 panic ! ( "Could not create runtime client SDK: {}" , e) ;
@@ -103,10 +103,10 @@ pub(crate) fn start_with_config<E: 'static, O: 'static>(
103103///
104104/// # Panics
105105/// The function panics if we cannot instantiate a new `RustRuntime` object.
106- pub ( crate ) fn start_with_runtime_client < ' env , E : ' static , O : ' static > (
106+ pub ( crate ) fn start_with_runtime_client < E , O > (
107107 f : Handler < E , O > ,
108108 func_settings : FunctionSettings ,
109- client : & ' env lambda_runtime_client :: RuntimeClient ,
109+ client : RuntimeClient ,
110110) where
111111 for < ' invocation > E : serde:: Deserialize < ' invocation > ,
112112 O : serde:: Serialize ,
@@ -125,15 +125,15 @@ pub(crate) fn start_with_runtime_client<'env, E: 'static, O: 'static>(
125125
126126/// Internal representation of the runtime object that polls for events and communicates
127127/// with the Runtime APIs
128- pub ( super ) struct Runtime < ' env , E : ' static , O : ' static > {
129- runtime_client : & ' env lambda_runtime_client :: RuntimeClient ,
128+ pub ( super ) struct Runtime < E , O > {
129+ runtime_client : RuntimeClient ,
130130 handler : Handler < E , O > ,
131131 max_retries : i8 ,
132132 settings : FunctionSettings ,
133133}
134134
135135// generic methods implementation
136- impl < ' env , E , O > Runtime < ' env , E , O > {
136+ impl < E , O > Runtime < E , O > {
137137 /// Creates a new instance of the `Runtime` object populated with the environment
138138 /// settings.
139139 ///
@@ -151,8 +151,8 @@ impl<'env, E, O> Runtime<'env, E, O> {
151151 f : Handler < E , O > ,
152152 config : FunctionSettings ,
153153 retries : i8 ,
154- client : & ' env lambda_runtime_client :: RuntimeClient ,
155- ) -> result:: Result < Runtime < ' env , E , O > , RuntimeError > {
154+ client : RuntimeClient ,
155+ ) -> result:: Result < Runtime < E , O > , RuntimeError > {
156156 debug ! (
157157 "Creating new runtime with {} max retries for endpoint {}" ,
158158 retries,
@@ -169,7 +169,7 @@ impl<'env, E, O> Runtime<'env, E, O> {
169169
170170// implementation of methods that require the Event and Output types
171171// to be compatible with `serde`'s Deserialize/Serialize.
172- impl < ' env , E , O > Runtime < ' env , E , O >
172+ impl < ' env , E , O > Runtime < E , O >
173173where
174174 for < ' de > E : serde:: Deserialize < ' de > ,
175175 O : serde:: Serialize ,
@@ -300,12 +300,12 @@ pub(crate) mod tests {
300300 use super :: * ;
301301 use context;
302302 use env;
303- use lambda_runtime_client as cli ;
303+ use lambda_runtime_client:: RuntimeClient ;
304304
305305 #[ test]
306306 fn runtime_invokes_handler ( ) {
307307 let config: & env:: ConfigProvider = & env:: tests:: MockConfigProvider { error : false } ;
308- let client: & lambda_runtime_client :: RuntimeClient = & cli :: HttpRuntimeClient :: new (
308+ let client = RuntimeClient :: new (
309309 config
310310 . get_runtime_api_endpoint ( )
311311 . expect ( "Could not get runtime endpoint" ) ,
0 commit comments