1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//
// Copyright 2018-2026 Accenture Technology
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//! The RPC reply listener — Rust port of Java's **`TemporaryInbox`**
//! (`org.platformlambda.core.services.TemporaryInbox` + `InboxBase.getHolder`):
//! **one reserved private route**, `temporary.inbox`, receives every RPC reply
//! and resolves the waiting caller through a **correlation-id-keyed registry**
//! — an RPC costs one map insert/remove, and no per-request route or route
//! prefix is ever claimed, so the `inbox.*` namespace belongs entirely to
//! applications (workflow apps commonly use routes like `inbox.approval` for
//! human-operator staging areas).
//!
//! `PostOffice::request` registers a unique correlation id here and sends the
//! request with `reply_to = temporary.inbox` and that id as the envelope `cid`
//! (the caller's original correlation id is restored on the reply — Java
//! `AsyncInbox.originalCid`). Any delivery addressed to `temporary.inbox` —
//! the worker's automatic reply *or* a manual `po.send(reply_to)` (the
//! `#[event_interceptor]` pattern) — reaches this service like any other
//! function, and it completes the caller's oneshot. A late reply after timeout
//! finds the entry gone and is dropped silently (Java parity). For the
//! fork-n-join multi-inbox case the correlation id is composite `{cid}-{seq}`;
//! the lookup strips after the LAST `-` exactly like Java (single-inbox ids
//! are dash-less uuids, so they never split).
//!
//! The route is registered at platform construction (and asserted by the
//! lifecycle's essential-service step, the Java `EssentialServiceLoader`
//! analog) — private, zero-tracing, 500 instances.
//!
//! **Deliberate divergences from Java** (doc'd, not silent):
//! - Java's reply address is origin-qualified (`temporary.inbox@{origin}`)
//! because the `route@origin` syntax selects a target instance under the
//! legacy Kafka service mesh. That burden is not carried here (Eric's
//! ruling): the reply address is the plain route name; an inbound
//! `@origin` suffix (e.g. from a Java peer's envelope) is parsed away and
//! never generated.
//! - Dispatch to this route is DIRECT on the sender's runtime (the reserved
//! engine-route path), like `event.script.manager`/`task.executor`: the
//! registered workers are the route's addressable identity, but a
//! multi-runtime process (test binaries) cannot rely on their liveness,
//! and a reply must always complete.
use HashMap;
use ;
use async_trait;
use oneshot;
use crateEventEnvelope;
use crate;
/// The reserved RPC reply-listener route (Java `TemporaryInbox.TEMPORARY_INBOX`).
pub const TEMPORARY_INBOX: &str = "temporary.inbox";
/// Create a new pending RPC entry: returns its unique correlation id (a
/// dash-less uuid — it must never contain `-`, see the composite-id split)
/// and the receiving end for the caller to await.
pub
/// Close a pending entry without a reply (timeout / send failure cleanup).
pub
/// The `temporary.inbox` service (Java `TemporaryInbox`): resolves the reply's
/// correlation id — stripping a composite `{cid}-{seq}` suffix on the last
/// `-`, Java parity — and hands the envelope to the waiting caller. A missing
/// entry (the caller timed out) drops the reply silently — the correct
/// outcome. The worker delivers the envelope to this route PRISTINE (no
/// metadata scrubbing or injection — see `worker_loop`), because the envelope
/// IS the payload the caller receives.
;