@@ -19,6 +19,7 @@ pub type HeaderMap = http::HeaderMap<String>;
1919
2020/// Service handler context.
2121pub struct Context < ' ctx > {
22+ invocation_id : String ,
2223 random_seed : u64 ,
2324 #[ cfg( feature = "rand" ) ]
2425 std_rng : rand:: prelude:: StdRng ,
@@ -27,6 +28,11 @@ pub struct Context<'ctx> {
2728}
2829
2930impl Context < ' _ > {
31+ /// Get invocation id.
32+ pub fn invocation_id ( & self ) -> & str {
33+ & self . invocation_id
34+ }
35+
3036 /// Get request headers.
3137 pub fn headers ( & self ) -> & HeaderMap {
3238 & self . headers
@@ -41,6 +47,7 @@ impl Context<'_> {
4147impl < ' ctx > From < ( & ' ctx ContextInternal , InputMetadata ) > for Context < ' ctx > {
4248 fn from ( value : ( & ' ctx ContextInternal , InputMetadata ) ) -> Self {
4349 Self {
50+ invocation_id : value. 1 . invocation_id ,
4451 random_seed : value. 1 . random_seed ,
4552 #[ cfg( feature = "rand" ) ]
4653 std_rng : rand:: prelude:: SeedableRng :: seed_from_u64 ( value. 1 . random_seed ) ,
@@ -52,6 +59,7 @@ impl<'ctx> From<(&'ctx ContextInternal, InputMetadata)> for Context<'ctx> {
5259
5360/// Object shared handler context.
5461pub struct SharedObjectContext < ' ctx > {
62+ invocation_id : String ,
5563 key : String ,
5664 random_seed : u64 ,
5765 #[ cfg( feature = "rand" ) ]
@@ -61,6 +69,11 @@ pub struct SharedObjectContext<'ctx> {
6169}
6270
6371impl SharedObjectContext < ' _ > {
72+ /// Get invocation id.
73+ pub fn invocation_id ( & self ) -> & str {
74+ & self . invocation_id
75+ }
76+
6477 /// Get object key.
6578 pub fn key ( & self ) -> & str {
6679 & self . key
@@ -80,6 +93,7 @@ impl SharedObjectContext<'_> {
8093impl < ' ctx > From < ( & ' ctx ContextInternal , InputMetadata ) > for SharedObjectContext < ' ctx > {
8194 fn from ( value : ( & ' ctx ContextInternal , InputMetadata ) ) -> Self {
8295 Self {
96+ invocation_id : value. 1 . invocation_id ,
8397 key : value. 1 . key ,
8498 random_seed : value. 1 . random_seed ,
8599 #[ cfg( feature = "rand" ) ]
@@ -92,6 +106,7 @@ impl<'ctx> From<(&'ctx ContextInternal, InputMetadata)> for SharedObjectContext<
92106
93107/// Object handler context.
94108pub struct ObjectContext < ' ctx > {
109+ invocation_id : String ,
95110 key : String ,
96111 random_seed : u64 ,
97112 #[ cfg( feature = "rand" ) ]
@@ -101,6 +116,11 @@ pub struct ObjectContext<'ctx> {
101116}
102117
103118impl ObjectContext < ' _ > {
119+ /// Get invocation id.
120+ pub fn invocation_id ( & self ) -> & str {
121+ & self . invocation_id
122+ }
123+
104124 /// Get object key.
105125 pub fn key ( & self ) -> & str {
106126 & self . key
@@ -120,6 +140,7 @@ impl ObjectContext<'_> {
120140impl < ' ctx > From < ( & ' ctx ContextInternal , InputMetadata ) > for ObjectContext < ' ctx > {
121141 fn from ( value : ( & ' ctx ContextInternal , InputMetadata ) ) -> Self {
122142 Self {
143+ invocation_id : value. 1 . invocation_id ,
123144 key : value. 1 . key ,
124145 random_seed : value. 1 . random_seed ,
125146 #[ cfg( feature = "rand" ) ]
@@ -132,6 +153,7 @@ impl<'ctx> From<(&'ctx ContextInternal, InputMetadata)> for ObjectContext<'ctx>
132153
133154/// Workflow shared handler context.
134155pub struct SharedWorkflowContext < ' ctx > {
156+ invocation_id : String ,
135157 key : String ,
136158 random_seed : u64 ,
137159 #[ cfg( feature = "rand" ) ]
@@ -143,6 +165,7 @@ pub struct SharedWorkflowContext<'ctx> {
143165impl < ' ctx > From < ( & ' ctx ContextInternal , InputMetadata ) > for SharedWorkflowContext < ' ctx > {
144166 fn from ( value : ( & ' ctx ContextInternal , InputMetadata ) ) -> Self {
145167 Self {
168+ invocation_id : value. 1 . invocation_id ,
146169 key : value. 1 . key ,
147170 random_seed : value. 1 . random_seed ,
148171 #[ cfg( feature = "rand" ) ]
@@ -154,6 +177,11 @@ impl<'ctx> From<(&'ctx ContextInternal, InputMetadata)> for SharedWorkflowContex
154177}
155178
156179impl SharedWorkflowContext < ' _ > {
180+ /// Get invocation id.
181+ pub fn invocation_id ( & self ) -> & str {
182+ & self . invocation_id
183+ }
184+
157185 /// Get workflow key.
158186 pub fn key ( & self ) -> & str {
159187 & self . key
@@ -172,6 +200,7 @@ impl SharedWorkflowContext<'_> {
172200
173201/// Workflow handler context.
174202pub struct WorkflowContext < ' ctx > {
203+ invocation_id : String ,
175204 key : String ,
176205 random_seed : u64 ,
177206 #[ cfg( feature = "rand" ) ]
@@ -183,6 +212,7 @@ pub struct WorkflowContext<'ctx> {
183212impl < ' ctx > From < ( & ' ctx ContextInternal , InputMetadata ) > for WorkflowContext < ' ctx > {
184213 fn from ( value : ( & ' ctx ContextInternal , InputMetadata ) ) -> Self {
185214 Self {
215+ invocation_id : value. 1 . invocation_id ,
186216 key : value. 1 . key ,
187217 random_seed : value. 1 . random_seed ,
188218 #[ cfg( feature = "rand" ) ]
@@ -194,6 +224,11 @@ impl<'ctx> From<(&'ctx ContextInternal, InputMetadata)> for WorkflowContext<'ctx
194224}
195225
196226impl WorkflowContext < ' _ > {
227+ /// Get invocation id.
228+ pub fn invocation_id ( & self ) -> & str {
229+ & self . invocation_id
230+ }
231+
197232 /// Get workflow key.
198233 pub fn key ( & self ) -> & str {
199234 & self . key
0 commit comments