@@ -44,7 +44,7 @@ pub struct LambdaProcessor {
4444 // Some(false) = not a durable function; flush logs normally.
4545 is_durable_function : Option < bool > ,
4646 // Logs held pending resolution, keyed by request_id.
47- // While is_durable_function is None every incoming log is stashed here so
47+ // While is_durable_function is None, every incoming log is stashed here so
4848 // we can decide whether to filter/tag it once the flag is known.
4949 // While is_durable_function is Some(true), logs whose request_id has no
5050 // durable execution context yet are also stashed here; they are drained
@@ -56,6 +56,8 @@ pub struct LambdaProcessor {
5656 durable_id_order : VecDeque < String > ,
5757}
5858
59+ const DURABLE_ID_MAP_CAPACITY : usize = 5 ;
60+
5961const OOM_ERRORS : [ & str ; 7 ] = [
6062 "fatal error: runtime: out of memory" , // Go
6163 "java.lang.OutOfMemoryError" , // Java
@@ -122,8 +124,8 @@ impl LambdaProcessor {
122124 is_managed_instance_mode,
123125 is_durable_function : None ,
124126 held_logs : HashMap :: new ( ) ,
125- durable_id_map : HashMap :: with_capacity ( 5 ) ,
126- durable_id_order : VecDeque :: with_capacity ( 5 ) ,
127+ durable_id_map : HashMap :: with_capacity ( DURABLE_ID_MAP_CAPACITY ) ,
128+ durable_id_order : VecDeque :: with_capacity ( DURABLE_ID_MAP_CAPACITY ) ,
127129 }
128130 }
129131
@@ -510,7 +512,7 @@ impl LambdaProcessor {
510512 if let ( Some ( id) , Some ( name) ) = ( execution_id, execution_name) {
511513 let is_new = !self . durable_id_map . contains_key ( request_id) ;
512514 if is_new {
513- if self . durable_id_order . len ( ) >= 5 {
515+ if self . durable_id_order . len ( ) >= DURABLE_ID_MAP_CAPACITY {
514516 if let Some ( oldest) = self . durable_id_order . pop_front ( ) {
515517 self . durable_id_map . remove ( & oldest) ;
516518 }
0 commit comments