@@ -59,9 +59,9 @@ pub struct Context {
5959 /// identity service.
6060 pub identity : Option < lambda_runtime_client:: CognitoIdentity > ,
6161
62- /// The deadline for the current handler execution in nanoseconds based
62+ /// The deadline for the current handler execution in milliseconds, based
6363 /// on a unix `MONOTONIC` clock.
64- pub ( super ) deadline : u128 ,
64+ pub ( super ) deadline : i64 ,
6565}
6666
6767impl Context {
@@ -102,9 +102,8 @@ impl Context {
102102
103103 /// Returns the remaining time in the execution in milliseconds. This is based on the
104104 /// deadline header passed by Lambda's Runtime APIs.
105- pub fn get_time_remaining_millis ( & self ) -> u128 {
106- let millis = Utc :: now ( ) . timestamp_millis ( ) ;
107- self . deadline - millis as u128
105+ pub fn get_time_remaining_millis ( & self ) -> i64 {
106+ self . deadline - Utc :: now ( ) . timestamp_millis ( )
108107 }
109108}
110109
@@ -114,11 +113,12 @@ pub(crate) mod tests {
114113 use env:: { self , ConfigProvider } ;
115114 use std:: { thread:: sleep, time} ;
116115
117- fn get_deadline ( secs : u8 ) -> u128 {
118- Utc :: now ( ) . timestamp_millis ( ) as u128 + ( u128:: from ( secs) * 1_000 )
116+ fn get_deadline ( timeout_secs : i64 ) -> i64 {
117+ let deadline = Utc :: now ( ) + chrono:: Duration :: seconds ( timeout_secs) ;
118+ deadline. timestamp_millis ( )
119119 }
120120
121- pub ( crate ) fn test_context ( deadline : u8 ) -> Context {
121+ pub ( crate ) fn test_context ( timeout_secs : i64 ) -> Context {
122122 Context {
123123 memory_limit_in_mb : 128 ,
124124 function_name : "test_func" . to_string ( ) ,
@@ -130,7 +130,7 @@ pub(crate) mod tests {
130130 log_group_name : "logGroup" . to_string ( ) ,
131131 client_context : Option :: default ( ) ,
132132 identity : Option :: default ( ) ,
133- deadline : get_deadline ( deadline ) ,
133+ deadline : get_deadline ( timeout_secs ) ,
134134 }
135135 }
136136
0 commit comments