pub struct RootRequestFailure { /* private fields */ }Expand description
Light, single-consumption source receipt: no exception body, original error, copied root facts, output handle, task/DB capability or account owner.
ⓘ
use saddle_observability::RootRequestFailure;
fn duplicate(f: RootRequestFailure) { let _ = f.clone(); }ⓘ
use saddle_observability::RootRequestFailure;
let f = RootRequestFailure {};Implementations§
Source§impl RootRequestFailure
impl RootRequestFailure
pub fn original_capture(&self) -> OriginalCaptureState
pub fn occurrence(&self) -> DiagnosticOccurrence
pub fn submission(&self) -> DiagnosticSubmission
pub fn source_view(&self) -> &RequestExecutionView
Sourcepub fn map_classification(self, classification: DiagnosticCode) -> Self
pub fn map_classification(self, classification: DiagnosticCode) -> Self
Examples found in repository?
examples/request_root_contract.rs (line 129)
62fn main() {
63 // Storage contract exercise only. R0/A/R must reserve the exact layouts before
64 // this constructor is enabled in a real admitted or rejection path.
65 let mut publisher = RequestRootPublisher::create(
66 ContextLabel::checked("saddle").unwrap(),
67 ContextFact::NotEstablished,
68 )
69 .unwrap();
70 let root = publisher.reference();
71 let early = root.view(
72 RequestLocalFacts::new(RequestViewPhase::Reading).with_task(ContextFact::Present(17)),
73 );
74 let read_error = std::io::Error::from(std::io::ErrorKind::UnexpectedEof);
75 let early_failure = RootDiagnosticScope::new(&early, None).source_error(
76 &read_error,
77 DiagnosticStage::RequestDecode,
78 RootRequestEvent::Ingress,
79 RootOutcomeFacts::default(),
80 );
81 let event = EventContext::new(
82 RequestIdentity::new("request-a").unwrap(),
83 RouteIdentity::new("example.live").unwrap(),
84 1,
85 )
86 .unwrap();
87 assert!(
88 publisher
89 .publish(
90 request_identity_group(
91 &call("0", 1, "entry", "app", "example.live"),
92 &event,
93 ContextFact::Present(ContextLabel::checked("local").unwrap())
94 )
95 .unwrap()
96 )
97 .is_ok()
98 );
99 let active = early
100 .refresh(&root)
101 .unwrap()
102 .with_phase(RequestViewPhase::Handler);
103 // Formal Boundary style: real child Call and event originate from its actual
104 // ProfuseContract request. Obs validates rather than inventing a child RPC.
105 let child_event = EventContext::new(
106 RequestIdentity::new("request-a").unwrap(),
107 RouteIdentity::new("receipt.invoke").unwrap(),
108 1,
109 )
110 .unwrap();
111 let child = request_child_view(
112 &active,
113 &call("0.1", 2, "local", "profusecontract", "invoke"),
114 &child_event,
115 )
116 .unwrap();
117 assert!(active.same_request(&child));
118 let (_, issuer) = DbPhysicalDispositionIssuer::issue().into_startup_and_request_issuer();
119 let (request, execution) = issuer.issue_request().unwrap();
120 // Real D passes &sqlx::Error here before driver_ref/business mapping. This
121 // standalone example uses the standard Error contract, with no DB dependency.
122 let raw_error = std::io::Error::new(
123 std::io::ErrorKind::PermissionDenied,
124 "original driver description",
125 );
126 let db_failure = database_source(&active, &request, &execution, None, &raw_error);
127 drop(raw_error);
128 let supervised = RootSupervisionReturn::<()>::failed(
129 db_failure.map_classification(DiagnosticCode::new("handler.failed").unwrap()),
130 );
131 let failure = supervised.consume().err().unwrap();
132 // Public projections contain no source body or root. Real Runtime must also
133 // finish the original physical pair, then drop all views before settlement.
134 let public = failure
135 .finish(&active, None, RootOutcomeFacts::default())
136 .ok()
137 .unwrap();
138 let early_public = early_failure
139 .finish(&active, None, RootOutcomeFacts::default())
140 .ok()
141 .unwrap();
142 let observer = Observer::with_writer(ObserverConfig::default(), std::io::sink()).unwrap();
143 let completed = RootDiagnosticScope::new(&active, None)
144 .start_stage(&observer, RootRequestEvent::Response)
145 .finish_nonfailure(RootOutcomeFacts {
146 axes: DiagnosticOutcomeAxes {
147 operation: OperationOutcome::Succeeded,
148 ..Default::default()
149 },
150 ..Default::default()
151 })
152 .ok()
153 .unwrap();
154 assert_eq!(completed, DiagnosticSubmission::OutputUnavailable);
155 assert_eq!(
156 RootDiagnosticScope::new(&active, None).ordinary(
157 &observer,
158 RootRequestEvent::Handler,
159 RootOutcomeFacts::default()
160 ),
161 DiagnosticSubmission::Enqueued
162 );
163 drop((publisher, root, early, active, child));
164 assert_eq!(
165 public.source_submission(),
166 DiagnosticSubmission::OutputUnavailable
167 );
168 assert_eq!(
169 early_public.terminal_submission(),
170 DiagnosticSubmission::OutputUnavailable
171 );
172 for (name, (payload, shared)) in ["root", "view", "child"]
173 .into_iter()
174 .zip(saddle_core::request_context::request_context_layouts())
175 {
176 println!(
177 "layout {name}: payload={} align={} arc_allocation={} arc_align={}",
178 payload.size(),
179 payload.align(),
180 shared.size(),
181 shared.align()
182 );
183 }
184 println!(
185 "layout receipt={} public={} root_ref={} view_ref={} identity_input={} bounded_detail={} borrowed_stage={}",
186 size_of::<RootRequestFailure>(),
187 size_of::<PublicRequestFailure>(),
188 size_of::<RequestRootRef>(),
189 size_of::<RequestExecutionView>(),
190 size_of::<RequestIdentityGroup>(),
191 size_of::<BoundedDiagnostic>(),
192 size_of::<RootActiveStage<'static>>()
193 );
194 println!("C consumer contract GO; production reservation/lifecycle NOT_RUN");
195 let layout = saddle_observability::root_diagnostic::request_logging_layouts();
196 let (stream, cycle, payload) = saddle_observability::root_diagnostic::original_capture_layout();
197 println!(
198 "layout original_stream={} align={} cycle_detector={} align={} payload_limit={} total_content_limit=none",
199 stream.size(),
200 stream.align(),
201 cycle.size(),
202 cycle.align(),
203 payload
204 );
205 println!(
206 "layout source_frame={} source_record={} emergency_packet={} emergency_slots={} ordinary_command={} ordinary_payload_max={}",
207 layout.source_frame.size(),
208 layout.source_record.size(),
209 layout.emergency_packet.size(),
210 layout.emergency_slots,
211 layout.ordinary_command.size(),
212 layout.ordinary_encoded_bytes_max
213 );
214}Sourcepub fn boundary(
self,
current: &RequestExecutionView,
output: Option<&EmergencyDiagnosticHandle>,
stage: RootRequestEvent,
axes: RootOutcomeFacts,
) -> Result<(Self, DiagnosticSubmission), Self>
pub fn boundary( self, current: &RequestExecutionView, output: Option<&EmergencyDiagnosticHandle>, stage: RootRequestEvent, axes: RootOutcomeFacts, ) -> Result<(Self, DiagnosticSubmission), Self>
Foreign-root rejection returns the original receipt for a legitimate retry.
Sourcepub fn finish(
self,
current: &RequestExecutionView,
output: Option<&EmergencyDiagnosticHandle>,
axes: RootOutcomeFacts,
) -> Result<PublicRequestFailure, Self>
pub fn finish( self, current: &RequestExecutionView, output: Option<&EmergencyDiagnosticHandle>, axes: RootOutcomeFacts, ) -> Result<PublicRequestFailure, Self>
Submit final reference, then consume all receipt references. Caller must release its other views/root before settling the original account.
Examples found in repository?
examples/request_root_contract.rs (line 135)
62fn main() {
63 // Storage contract exercise only. R0/A/R must reserve the exact layouts before
64 // this constructor is enabled in a real admitted or rejection path.
65 let mut publisher = RequestRootPublisher::create(
66 ContextLabel::checked("saddle").unwrap(),
67 ContextFact::NotEstablished,
68 )
69 .unwrap();
70 let root = publisher.reference();
71 let early = root.view(
72 RequestLocalFacts::new(RequestViewPhase::Reading).with_task(ContextFact::Present(17)),
73 );
74 let read_error = std::io::Error::from(std::io::ErrorKind::UnexpectedEof);
75 let early_failure = RootDiagnosticScope::new(&early, None).source_error(
76 &read_error,
77 DiagnosticStage::RequestDecode,
78 RootRequestEvent::Ingress,
79 RootOutcomeFacts::default(),
80 );
81 let event = EventContext::new(
82 RequestIdentity::new("request-a").unwrap(),
83 RouteIdentity::new("example.live").unwrap(),
84 1,
85 )
86 .unwrap();
87 assert!(
88 publisher
89 .publish(
90 request_identity_group(
91 &call("0", 1, "entry", "app", "example.live"),
92 &event,
93 ContextFact::Present(ContextLabel::checked("local").unwrap())
94 )
95 .unwrap()
96 )
97 .is_ok()
98 );
99 let active = early
100 .refresh(&root)
101 .unwrap()
102 .with_phase(RequestViewPhase::Handler);
103 // Formal Boundary style: real child Call and event originate from its actual
104 // ProfuseContract request. Obs validates rather than inventing a child RPC.
105 let child_event = EventContext::new(
106 RequestIdentity::new("request-a").unwrap(),
107 RouteIdentity::new("receipt.invoke").unwrap(),
108 1,
109 )
110 .unwrap();
111 let child = request_child_view(
112 &active,
113 &call("0.1", 2, "local", "profusecontract", "invoke"),
114 &child_event,
115 )
116 .unwrap();
117 assert!(active.same_request(&child));
118 let (_, issuer) = DbPhysicalDispositionIssuer::issue().into_startup_and_request_issuer();
119 let (request, execution) = issuer.issue_request().unwrap();
120 // Real D passes &sqlx::Error here before driver_ref/business mapping. This
121 // standalone example uses the standard Error contract, with no DB dependency.
122 let raw_error = std::io::Error::new(
123 std::io::ErrorKind::PermissionDenied,
124 "original driver description",
125 );
126 let db_failure = database_source(&active, &request, &execution, None, &raw_error);
127 drop(raw_error);
128 let supervised = RootSupervisionReturn::<()>::failed(
129 db_failure.map_classification(DiagnosticCode::new("handler.failed").unwrap()),
130 );
131 let failure = supervised.consume().err().unwrap();
132 // Public projections contain no source body or root. Real Runtime must also
133 // finish the original physical pair, then drop all views before settlement.
134 let public = failure
135 .finish(&active, None, RootOutcomeFacts::default())
136 .ok()
137 .unwrap();
138 let early_public = early_failure
139 .finish(&active, None, RootOutcomeFacts::default())
140 .ok()
141 .unwrap();
142 let observer = Observer::with_writer(ObserverConfig::default(), std::io::sink()).unwrap();
143 let completed = RootDiagnosticScope::new(&active, None)
144 .start_stage(&observer, RootRequestEvent::Response)
145 .finish_nonfailure(RootOutcomeFacts {
146 axes: DiagnosticOutcomeAxes {
147 operation: OperationOutcome::Succeeded,
148 ..Default::default()
149 },
150 ..Default::default()
151 })
152 .ok()
153 .unwrap();
154 assert_eq!(completed, DiagnosticSubmission::OutputUnavailable);
155 assert_eq!(
156 RootDiagnosticScope::new(&active, None).ordinary(
157 &observer,
158 RootRequestEvent::Handler,
159 RootOutcomeFacts::default()
160 ),
161 DiagnosticSubmission::Enqueued
162 );
163 drop((publisher, root, early, active, child));
164 assert_eq!(
165 public.source_submission(),
166 DiagnosticSubmission::OutputUnavailable
167 );
168 assert_eq!(
169 early_public.terminal_submission(),
170 DiagnosticSubmission::OutputUnavailable
171 );
172 for (name, (payload, shared)) in ["root", "view", "child"]
173 .into_iter()
174 .zip(saddle_core::request_context::request_context_layouts())
175 {
176 println!(
177 "layout {name}: payload={} align={} arc_allocation={} arc_align={}",
178 payload.size(),
179 payload.align(),
180 shared.size(),
181 shared.align()
182 );
183 }
184 println!(
185 "layout receipt={} public={} root_ref={} view_ref={} identity_input={} bounded_detail={} borrowed_stage={}",
186 size_of::<RootRequestFailure>(),
187 size_of::<PublicRequestFailure>(),
188 size_of::<RequestRootRef>(),
189 size_of::<RequestExecutionView>(),
190 size_of::<RequestIdentityGroup>(),
191 size_of::<BoundedDiagnostic>(),
192 size_of::<RootActiveStage<'static>>()
193 );
194 println!("C consumer contract GO; production reservation/lifecycle NOT_RUN");
195 let layout = saddle_observability::root_diagnostic::request_logging_layouts();
196 let (stream, cycle, payload) = saddle_observability::root_diagnostic::original_capture_layout();
197 println!(
198 "layout original_stream={} align={} cycle_detector={} align={} payload_limit={} total_content_limit=none",
199 stream.size(),
200 stream.align(),
201 cycle.size(),
202 cycle.align(),
203 payload
204 );
205 println!(
206 "layout source_frame={} source_record={} emergency_packet={} emergency_slots={} ordinary_command={} ordinary_payload_max={}",
207 layout.source_frame.size(),
208 layout.source_record.size(),
209 layout.emergency_packet.size(),
210 layout.emergency_slots,
211 layout.ordinary_command.size(),
212 layout.ordinary_encoded_bytes_max
213 );
214}Auto Trait Implementations§
impl Freeze for RootRequestFailure
impl RefUnwindSafe for RootRequestFailure
impl Send for RootRequestFailure
impl Sync for RootRequestFailure
impl Unpin for RootRequestFailure
impl UnsafeUnpin for RootRequestFailure
impl UnwindSafe for RootRequestFailure
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more