-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TerminateAgreement endpoint #832
Conversation
…centralized/termag-ep
cc8d2fe
to
476e5d0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that we can't distinguish between Provider and Requestor Agreement in REST endpoints (like in GetAgreement), but here the problem is much bigger, because we have to know it, to fill terminator
field in AgreementTerminatedEvent
. But the way note, that we broke GetAgreement endpoint by adding AppSessionId.
I'm afraid we have to address these issues on specification level. @tworec
reason: Option<String>, | ||
owner_type: OwnerType, | ||
) -> DbResult<bool> { | ||
log::debug!("Termination reason: {:?}", reason); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will be ugly log:
Some("Reason")
Maybe you should implement something like .display()
core/market/src/db/dao/agreement.rs
Outdated
let event = NewAgreementEvent { | ||
agreement_id: id.clone(), | ||
reason: reason, | ||
event_type: AgreementEventType::Terminated, | ||
issuer: owner_type, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
signature is not optional for AgreementTerminatedEvent
but this is part of #781
778b82c
to
01def78
Compare
01def78
to
8682a4d
Compare
if let Some(s) = reason { | ||
Reason::from_json_reason(JsonReason { | ||
json: serde_json::from_str(s)?, | ||
})?; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if let Some(s) = reason { | |
Reason::from_json_reason(JsonReason { | |
json: serde_json::from_str(s)?, | |
})?; | |
}; | |
if let Some(s) = reason { | |
serde_json::from_str::<Reason>(s)? | |
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even:
Ok(if let Some(s) = reason {
serde_json::from_str::<Reason>(s)?;
})
@@ -431,7 +431,14 @@ impl CommonBroker { | |||
|
|||
dao.terminate(&agreement_id, msg.reason, owner_type) | |||
.await | |||
.map_err(|_e| RemoteAgreementError::InternalError(agreement_id.clone()))?; | |||
.map_err(|e| { | |||
log::info!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would say it is even warn
, because it would leave Provider and Requestor in inconsistent state
Additional tests and fixes to terminate agreement
…tests Terminate Agreement tests
d09beb2
to
6394a2f
Compare
verify_reason(reason.as_ref())?; | ||
let dao = self.db.as_dao::<AgreementDao>(); | ||
log::debug!( | ||
"Getting agreement. id: {:?}, agrid: {}, reason: {:?}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't display using debug if it is possible
fixes: #727
(just a branch name change from #792 to trigger market tests)