File tree Expand file tree Collapse file tree 3 files changed +31
-58
lines changed
relay-server/src/processing Expand file tree Collapse file tree 3 files changed +31
-58
lines changed Original file line number Diff line number Diff line change @@ -336,31 +336,4 @@ impl Forward for ErrorOutput {
336336 } )
337337 . map_err ( |err| err. map ( |_| ( ) ) )
338338 }
339-
340- #[ cfg( feature = "processing" ) ]
341- fn forward_store (
342- self ,
343- s : processing:: StoreHandle < ' _ > ,
344- ctx : processing:: ForwardContext < ' _ > ,
345- ) -> Result < ( ) , Rejected < ( ) > > {
346- let envelope = self . serialize_envelope ( ctx) ?;
347- let envelope = ManagedEnvelope :: from ( envelope) . into_processed ( ) ;
348-
349- let has_attachments = envelope
350- . envelope ( )
351- . items ( )
352- . any ( |item| item. ty ( ) == & ItemType :: Attachment ) ;
353- let use_objectstore = || {
354- let options = & ctx. global_config . options ;
355- crate :: utils:: sample ( options. objectstore_attachments_sample_rate ) . is_keep ( )
356- } ;
357-
358- if has_attachments && use_objectstore ( ) {
359- s. send_to_objectstore ( crate :: services:: store:: StoreEnvelope { envelope } ) ;
360- } else {
361- s. send_to_store ( crate :: services:: store:: StoreEnvelope { envelope } ) ;
362- }
363-
364- Ok ( ( ) )
365- }
366339}
Original file line number Diff line number Diff line change @@ -61,8 +61,37 @@ pub trait Forward {
6161 ///
6262 /// This function must only be called when Relay is configured to be in processing mode.
6363 #[ cfg( feature = "processing" ) ]
64- fn forward_store ( self , s : StoreHandle < ' _ > , ctx : ForwardContext < ' _ > )
65- -> Result < ( ) , Rejected < ( ) > > ;
64+ fn forward_store (
65+ self ,
66+ s : StoreHandle < ' _ > ,
67+ ctx : ForwardContext < ' _ > ,
68+ ) -> Result < ( ) , Rejected < ( ) > >
69+ where
70+ Self : Sized ,
71+ {
72+ use crate :: envelope:: ItemType ;
73+ use crate :: managed:: ManagedEnvelope ;
74+
75+ let envelope = self . serialize_envelope ( ctx) ?;
76+ let envelope = ManagedEnvelope :: from ( envelope) . into_processed ( ) ;
77+
78+ let has_attachments = envelope
79+ . envelope ( )
80+ . items ( )
81+ . any ( |item| item. ty ( ) == & ItemType :: Attachment ) ;
82+ let use_objectstore = || {
83+ let options = & ctx. global_config . options ;
84+ crate :: utils:: sample ( options. objectstore_attachments_sample_rate ) . is_keep ( )
85+ } ;
86+
87+ if has_attachments && use_objectstore ( ) {
88+ s. send_to_objectstore ( crate :: services:: store:: StoreEnvelope { envelope } ) ;
89+ } else {
90+ s. send_to_store ( crate :: services:: store:: StoreEnvelope { envelope } ) ;
91+ }
92+
93+ Ok ( ( ) )
94+ }
6695}
6796
6897/// Context passed to [`Forward`].
Original file line number Diff line number Diff line change @@ -65,33 +65,4 @@ impl Forward for TransactionOutput {
6565 } ) ,
6666 }
6767 }
68-
69- #[ cfg( feature = "processing" ) ]
70- fn forward_store (
71- self ,
72- s : StoreHandle < ' _ > ,
73- ctx : ForwardContext < ' _ > ,
74- ) -> Result < ( ) , Rejected < ( ) > > {
75- use crate :: envelope:: ItemType ;
76-
77- let envelope = self . serialize_envelope ( ctx) ?;
78- let envelope = ManagedEnvelope :: from ( envelope) . into_processed ( ) ;
79-
80- let has_attachments = envelope
81- . envelope ( )
82- . items ( )
83- . any ( |item| item. ty ( ) == & ItemType :: Attachment ) ;
84- let use_objectstore = || {
85- let options = & ctx. global_config . options ;
86- crate :: utils:: sample ( options. objectstore_attachments_sample_rate ) . is_keep ( )
87- } ;
88-
89- if has_attachments && use_objectstore ( ) {
90- s. send_to_objectstore ( crate :: services:: store:: StoreEnvelope { envelope } ) ;
91- } else {
92- s. send_to_store ( crate :: services:: store:: StoreEnvelope { envelope } ) ;
93- }
94-
95- Ok ( ( ) )
96- }
9768}
You can’t perform that action at this time.
0 commit comments