diff --git a/lambda-runtime/src/types.rs b/lambda-runtime/src/types.rs index 1cfab2fc..31f4c8a2 100644 --- a/lambda-runtime/src/types.rs +++ b/lambda-runtime/src/types.rs @@ -1,7 +1,11 @@ use crate::{Config, Error}; use http::{HeaderMap, HeaderValue}; use serde::{Deserialize, Serialize}; -use std::{collections::HashMap, convert::TryFrom}; +use std::{ + collections::HashMap, + convert::TryFrom, + time::{Duration, SystemTime}, +}; #[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -375,4 +379,9 @@ impl Context { ..self } } + + /// The execution deadline for the current invocation. + pub fn deadline(&self) -> SystemTime { + SystemTime::UNIX_EPOCH + Duration::from_millis(self.deadline) + } }