From 7019dc235fac123d2e52e89bd0123dc18836ba49 Mon Sep 17 00:00:00 2001 From: Daniel Cormier Date: Fri, 6 Jan 2023 10:26:34 -0500 Subject: [PATCH] Added `Context::deadline(&self) -> SystemTime` --- lambda-runtime/src/types.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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) + } }