File tree Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,7 @@ mod undeliverable;
127
127
/// For [`Undeliverable`], a message type for delivery failures.
128
128
pub use undeliverable:: Undeliverable ;
129
129
pub use undeliverable:: UndeliverableMessageError ;
130
+ pub use undeliverable:: custom_monitored_return_handle;
130
131
pub use undeliverable:: monitored_return_handle; // TODO: Audit
131
132
pub use undeliverable:: supervise_undeliverable_messages;
132
133
/// For [`MailboxAdminMessage`], a message type for mailbox administration.
Original file line number Diff line number Diff line change @@ -70,6 +70,24 @@ pub fn monitored_return_handle() -> PortHandle<Undeliverable<MessageEnvelope>> {
70
70
return_handle. clone ( )
71
71
}
72
72
73
+ /// Now that monitored return handles are rare, it's becoming helpful
74
+ /// to get insights into where they are getting used (so that they can
75
+ /// be eliminated and replaced with something better).
76
+ #[ track_caller]
77
+ pub fn custom_monitored_return_handle ( caller : & str ) -> PortHandle < Undeliverable < MessageEnvelope > > {
78
+ let caller = caller. to_owned ( ) ;
79
+ let ( return_handle, mut rx) = new_undeliverable_port ( ) ;
80
+ tokio:: task:: spawn ( async move {
81
+ while let Ok ( Undeliverable ( mut envelope) ) = rx. recv ( ) . await {
82
+ envelope. try_set_error ( DeliveryError :: BrokenLink (
83
+ "message returned to undeliverable port" . to_string ( ) ,
84
+ ) ) ;
85
+ tracing:: error!( "{caller} took back an undeliverable message: {}" , envelope) ;
86
+ }
87
+ } ) ;
88
+ return_handle
89
+ }
90
+
73
91
/// Returns a message envelope to its original sender.
74
92
pub ( crate ) fn return_undeliverable (
75
93
return_handle : PortHandle < Undeliverable < MessageEnvelope > > ,
Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ impl ProcMesh {
193
193
}
194
194
router
195
195
. clone ( )
196
- . serve ( router_rx, mailbox:: monitored_return_handle ( ) ) ;
196
+ . serve ( router_rx, mailbox:: custom_monitored_return_handle ( "router" ) ) ;
197
197
198
198
// Set up a client proc for the mesh itself, so that we can attach ourselves
199
199
// to it, and communicate with the agents. We wire it into the same router as
@@ -207,9 +207,10 @@ impl ProcMesh {
207
207
client_proc_id. clone ( ) ,
208
208
BoxedMailboxSender :: new ( router. clone ( ) ) ,
209
209
) ;
210
- client_proc
211
- . clone ( )
212
- . serve ( client_rx, mailbox:: monitored_return_handle ( ) ) ;
210
+ client_proc. clone ( ) . serve (
211
+ client_rx,
212
+ mailbox:: custom_monitored_return_handle ( "client proc" ) ,
213
+ ) ;
213
214
router. bind ( client_proc_id. clone ( ) . into ( ) , client_proc_addr. clone ( ) ) ;
214
215
215
216
// Bind this router to the global router, to enable cross-mesh routing.
You can’t perform that action at this time.
0 commit comments