Repository: awslabs/aws-lambda-rust-runtime (language: rust)

Issue:
feat: use rc to avoid allocating a new string for extension_id
*Issue #, if available:* potential fix for #614

*Description of changes:*
Using a RC around the extension id. 
Now it clones the RC for each event which is way lighter than cloning the full extension_id string

⚠️ this is a breaking change as LambdaEvent is public

By submitting this pull request

- [x] I confirm that my contribution is made under the terms of the Apache 2.0 license.
- [x] I confirm that I've made a best effort attempt to update all relevant documentation.



Discussion / hints:

Fix patch:
diff --git a/lambda-extension/src/events.rs b/lambda-extension/src/events.rs
index 87fd62a4..c61fc9f0 100644
--- a/lambda-extension/src/events.rs
+++ b/lambda-extension/src/events.rs
@@ -55,17 +55,12 @@ impl NextEvent {
 /// Wrapper with information about the next
 /// event that the Lambda Runtime is going to process
 pub struct LambdaEvent {
-    /// ID assigned to this extension by the Lambda Runtime
-    pub extension_id: String,
     /// Next incoming event
     pub next: NextEvent,
 }
 
 impl LambdaEvent {
-    pub(crate) fn new(ex_id: &str, next: NextEvent) -> LambdaEvent {
-        LambdaEvent {
-            extension_id: ex_id.into(),
-            next,
-        }
+    pub(crate) fn new(next: NextEvent) -> LambdaEvent {
+        LambdaEvent { next }
     }
 }
diff --git a/lambda-extension/src/extension.rs b/lambda-extension/src/extension.rs
index 776e2fdf..52fe5c31 100644
--- a/lambda-extension/src/extension.rs
+++ b/lambda-extension/src/extension.rs
@@ -315,7 +315,7 @@ where
             let event: NextEvent = serde_json::from_slice(&body)?;
             let is_invoke = event.is_invoke();
 
-            let event = LambdaEvent::new(extension_id, event);
+            let event = LambdaEvent::new(event);
 
             let ep = match ep.ready().await {
                 Ok(ep) => ep,


Test patch: