feat: unify object observation API
This commit is contained in:
@@ -50,7 +50,7 @@ impl Transport for ScriptedTransport {
|
||||
detail: "scripted local conversion failure".into(),
|
||||
});
|
||||
}
|
||||
if self.fail_tree_prepare && request.uri().path().ends_with("/v1/fetch_tree") {
|
||||
if self.fail_tree_prepare && request.uri().path().ends_with("/v1/observe") {
|
||||
return Err(TransportError {
|
||||
kind: TransportErrorKind::Disconnect,
|
||||
detail: "scripted tree conversion failure".into(),
|
||||
@@ -61,7 +61,7 @@ impl Transport for ScriptedTransport {
|
||||
|
||||
fn execute(&self, request: Self::Prepared) -> Result<Response<Vec<u8>>, TransportError> {
|
||||
let sequence = self.sequence.fetch_add(1, Ordering::AcqRel);
|
||||
if request.uri().path().ends_with("/v1/fetch_tree")
|
||||
if request.uri().path().ends_with("/v1/observe")
|
||||
&& self
|
||||
.root_tree_protocol_failures
|
||||
.fetch_update(Ordering::AcqRel, Ordering::Acquire, |remaining| {
|
||||
@@ -70,7 +70,7 @@ impl Transport for ScriptedTransport {
|
||||
.is_ok()
|
||||
{
|
||||
return Ok(encode_protocol_error_response(
|
||||
ProtocolInteraction::FetchTree,
|
||||
ProtocolInteraction::Observe,
|
||||
&ProtocolError {
|
||||
code: ProtocolErrorCode::Internal,
|
||||
message: "scripted startup failure".into(),
|
||||
@@ -80,9 +80,9 @@ impl Transport for ScriptedTransport {
|
||||
.expect("encode tree failure"));
|
||||
}
|
||||
if self.delayed_after_startup && sequence > 0 {
|
||||
// Each refresh starts object then tree. Make the first pair lose to
|
||||
// the second pair to exercise exact RequestId ownership.
|
||||
let delay = if matches!(sequence, 1 | 2) { 80 } else { 5 };
|
||||
// Delay the first refresh so the second wins and exercises exact
|
||||
// RequestId ownership.
|
||||
let delay = if sequence == 1 { 80 } else { 5 };
|
||||
thread::sleep(Duration::from_millis(delay));
|
||||
}
|
||||
if self.panic_calls && request.uri().path().ends_with("/v1/call_operation") {
|
||||
|
||||
Reference in New Issue
Block a user