1212
1313pub mod client;
1414
15+ use std:: borrow:: Cow ;
16+ use std:: hash:: Hash ;
17+ use std:: ops:: Deref ;
18+ use std:: str:: FromStr ;
19+ use std:: time:: Duration ;
20+ use std:: { cmp, fmt} ;
21+
22+ use bytes:: Bytes ;
23+ use bytestring:: ByteString ;
24+ use opentelemetry:: trace:: { SpanContext , SpanId , TraceFlags , TraceState } ;
25+ use serde_with:: { DisplayFromStr , FromInto , serde_as} ;
26+
1527use crate :: errors:: InvocationError ;
1628use crate :: identifiers:: {
1729 DeploymentId , EntryIndex , IdempotencyId , InvocationId , PartitionKey ,
1830 PartitionProcessorRpcRequestId , ServiceId , SubscriptionId , WithInvocationId , WithPartitionKey ,
1931} ;
2032use crate :: journal_v2:: { CompletionId , GetInvocationOutputResult , Signal } ;
33+ use crate :: logs:: { HasRecordKeys , Keys } ;
2134use crate :: time:: MillisSinceEpoch ;
22- use crate :: { GenerationalNodeId , RestateVersion } ;
23-
24- use bytes:: Bytes ;
25- use bytestring:: ByteString ;
26- use opentelemetry:: trace:: { SpanContext , SpanId , TraceFlags , TraceState } ;
27- use serde_with:: { DisplayFromStr , FromInto , serde_as} ;
28- use std:: borrow:: Cow ;
29- use std:: hash:: Hash ;
30- use std:: ops:: Deref ;
31- use std:: str:: FromStr ;
32- use std:: time:: Duration ;
33- use std:: { cmp, fmt} ;
35+ use crate :: {
36+ GenerationalNodeId , RestateVersion , bilrost_storage_encode_decode,
37+ flexbuffers_storage_encode_decode,
38+ } ;
3439
3540// Re-exporting opentelemetry [`TraceId`] to avoid having to import opentelemetry in all crates.
3641pub use opentelemetry:: trace:: TraceId ;
@@ -435,6 +440,14 @@ pub struct ServiceInvocation {
435440 pub restate_version : RestateVersion ,
436441}
437442
443+ flexbuffers_storage_encode_decode ! ( ServiceInvocation ) ;
444+
445+ impl HasRecordKeys for ServiceInvocation {
446+ fn record_keys ( & self ) -> Keys {
447+ Keys :: Single ( self . invocation_id . partition_key ( ) )
448+ }
449+ }
450+
438451#[ derive( Debug , Copy , Clone , PartialEq , Eq , serde:: Serialize , serde:: Deserialize ) ]
439452#[ serde(
440453 from = "serde_hacks::SubmitNotificationSink" ,
@@ -577,12 +590,20 @@ pub struct InvocationResponse {
577590 pub result : ResponseResult ,
578591}
579592
593+ flexbuffers_storage_encode_decode ! ( InvocationResponse ) ;
594+
580595impl WithInvocationId for InvocationResponse {
581596 fn invocation_id ( & self ) -> InvocationId {
582597 self . target . invocation_id ( )
583598 }
584599}
585600
601+ impl HasRecordKeys for InvocationResponse {
602+ fn record_keys ( & self ) -> Keys {
603+ Keys :: Single ( self . partition_key ( ) )
604+ }
605+ }
606+
586607#[ derive( Debug , Clone , PartialEq , Eq , serde:: Serialize , serde:: Deserialize ) ]
587608pub enum ResponseResult {
588609 Success ( Bytes ) ,
@@ -623,12 +644,20 @@ pub struct GetInvocationOutputResponse {
623644 pub result : GetInvocationOutputResult ,
624645}
625646
647+ bilrost_storage_encode_decode ! ( GetInvocationOutputResponse ) ;
648+
626649impl WithInvocationId for GetInvocationOutputResponse {
627650 fn invocation_id ( & self ) -> InvocationId {
628651 self . target . invocation_id ( )
629652 }
630653}
631654
655+ impl HasRecordKeys for GetInvocationOutputResponse {
656+ fn record_keys ( & self ) -> Keys {
657+ Keys :: Single ( self . partition_key ( ) )
658+ }
659+ }
660+
632661/// Definition of the sink where to send the result of a service invocation.
633662#[ derive( Debug , PartialEq , Eq , Clone , Hash , serde:: Serialize , serde:: Deserialize ) ]
634663#[ serde(
@@ -944,6 +973,14 @@ pub struct InvocationTermination {
944973 pub response_sink : Option < InvocationMutationResponseSink > ,
945974}
946975
976+ flexbuffers_storage_encode_decode ! ( InvocationTermination ) ;
977+
978+ impl HasRecordKeys for InvocationTermination {
979+ fn record_keys ( & self ) -> crate :: logs:: Keys {
980+ Keys :: Single ( self . invocation_id . partition_key ( ) )
981+ }
982+ }
983+
947984/// Flavor of the termination. Can be kill (hard stop) or graceful cancel.
948985#[ derive(
949986 Debug , Clone , Copy , Eq , PartialEq , serde:: Serialize , serde:: Deserialize , bilrost:: Enumeration ,
@@ -963,12 +1000,20 @@ pub struct PurgeInvocationRequest {
9631000 pub response_sink : Option < InvocationMutationResponseSink > ,
9641001}
9651002
1003+ flexbuffers_storage_encode_decode ! ( PurgeInvocationRequest ) ;
1004+
9661005impl WithInvocationId for PurgeInvocationRequest {
9671006 fn invocation_id ( & self ) -> InvocationId {
9681007 self . invocation_id
9691008 }
9701009}
9711010
1011+ impl HasRecordKeys for PurgeInvocationRequest {
1012+ fn record_keys ( & self ) -> Keys {
1013+ Keys :: Single ( self . invocation_id . partition_key ( ) )
1014+ }
1015+ }
1016+
9721017/// Message to resume an invocation.
9731018#[ derive( Debug , Clone , Eq , PartialEq , serde:: Serialize , serde:: Deserialize ) ]
9741019pub struct ResumeInvocationRequest {
@@ -979,12 +1024,20 @@ pub struct ResumeInvocationRequest {
9791024 pub response_sink : Option < InvocationMutationResponseSink > ,
9801025}
9811026
1027+ flexbuffers_storage_encode_decode ! ( ResumeInvocationRequest ) ;
1028+
9821029impl WithInvocationId for ResumeInvocationRequest {
9831030 fn invocation_id ( & self ) -> InvocationId {
9841031 self . invocation_id
9851032 }
9861033}
9871034
1035+ impl HasRecordKeys for ResumeInvocationRequest {
1036+ fn record_keys ( & self ) -> Keys {
1037+ Keys :: Single ( self . invocation_id . partition_key ( ) )
1038+ }
1039+ }
1040+
9881041/// Message to restart an invocation.
9891042#[ derive( Debug , Clone , Eq , PartialEq , serde:: Serialize , serde:: Deserialize ) ]
9901043pub struct RestartAsNewInvocationRequest {
@@ -1001,12 +1054,20 @@ pub struct RestartAsNewInvocationRequest {
10011054 pub response_sink : Option < InvocationMutationResponseSink > ,
10021055}
10031056
1057+ flexbuffers_storage_encode_decode ! ( RestartAsNewInvocationRequest ) ;
1058+
10041059impl WithInvocationId for RestartAsNewInvocationRequest {
10051060 fn invocation_id ( & self ) -> InvocationId {
10061061 self . invocation_id
10071062 }
10081063}
10091064
1065+ impl HasRecordKeys for RestartAsNewInvocationRequest {
1066+ fn record_keys ( & self ) -> Keys {
1067+ Keys :: Single ( self . invocation_id . partition_key ( ) )
1068+ }
1069+ }
1070+
10101071// We use this struct instead of SpanContext as it is serialisable and allows us to use TraceStateDef
10111072#[ serde_as]
10121073#[ derive( Debug , PartialEq , Eq , Clone , serde:: Serialize , serde:: Deserialize ) ]
@@ -1320,25 +1381,41 @@ pub struct AttachInvocationRequest {
13201381 pub response_sink : ServiceInvocationResponseSink ,
13211382}
13221383
1384+ flexbuffers_storage_encode_decode ! ( AttachInvocationRequest ) ;
1385+
13231386impl WithPartitionKey for AttachInvocationRequest {
13241387 fn partition_key ( & self ) -> PartitionKey {
13251388 self . invocation_query . partition_key ( )
13261389 }
13271390}
13281391
1392+ impl HasRecordKeys for AttachInvocationRequest {
1393+ fn record_keys ( & self ) -> Keys {
1394+ Keys :: Single ( self . partition_key ( ) )
1395+ }
1396+ }
1397+
13291398/// Represents a request to notify a signal to an invocation
13301399#[ derive( Debug , Clone , PartialEq , Eq , serde:: Serialize , serde:: Deserialize ) ]
13311400pub struct NotifySignalRequest {
13321401 pub invocation_id : InvocationId ,
13331402 pub signal : Signal ,
13341403}
13351404
1405+ flexbuffers_storage_encode_decode ! ( NotifySignalRequest ) ;
1406+
13361407impl WithInvocationId for NotifySignalRequest {
13371408 fn invocation_id ( & self ) -> InvocationId {
13381409 self . invocation_id
13391410 }
13401411}
13411412
1413+ impl HasRecordKeys for NotifySignalRequest {
1414+ fn record_keys ( & self ) -> Keys {
1415+ Keys :: Single ( self . partition_key ( ) )
1416+ }
1417+ }
1418+
13421419/// The invocation epoch represents the restarts count of the invocation, as seen from the Partition processor.
13431420pub type InvocationEpoch = u32 ;
13441421
0 commit comments