Closed sophokles73 closed 2 months ago
Personally, I would be in favor of passing in a UMessage
, which would allow a UTransport implementation to do both, either pass in a UMessage
returned from a service provider as is or manually create a UMessage
in case of a transport error.
WDYT @PLeVasseur @AnotherDaniel ?
I'm not sure, but at least using UStatus
is enough for me now. I can add some messages in the UStatus
to describe what kind of error is.
For example, this is how it works in up-client-zenoh-rust:
https://github.com/ZettaScaleLabs/up-client-zenoh-rust/blob/680dc87ea334ae54e07a361a8d2138f7aac70d89/src/utransport.rs#L268
Indeed passing UMessage
allows users to do more things in on_error
, but it's a little cumbersome if we don't have UMessage and need to create an empty one to return. (Maybe using Option
instead?)
Indeed passing
UMessage
allows users to do more things inon_error
, but it's a little cumbersome if we don't have UMessage and need to create an empty one to return. (Maybe usingOption
instead?)
I think this is a good point. Could be that for some internal error reason there is no UMessage
available.
Feels a little weird for the API to be UListener::on_error(Result<UMessage, UStatus>)
, but I suppose it could allow for handling cases where the implementor of UTransport
is unable to provide the UMessage
.
Feels a little weird for the API to be
UListener::on_error(Result<UMessage, UStatus>)
, but I suppose it could allow for handling cases where the implementor ofUTransport
is unable to provide theUMessage
.
How about this? UListener::on_error(UStatus, Option<UMessage>)
Users only need to provide UMessage
if there is a valid UMessage
The idea would be to have
fn on_error(error: UMessage);
The message would either come directly from the service implementation or the transport would create it manually if something goes wrong, e.g. when forwarding a request message. In the latter case, the transport could copy the request message's UAttributes (to provide for context), swap the source and dest and set a commstatus other than OK. It could then add a UStatus as the message payload.
WDYT?
IMHO, I think extracting UStatus from UPayload is a little not intuitive and it would mix with the original UPayload. It would be better to separate them.
IMHO, I think extracting UStatus from UPayload is a little not intuitive and it would mix with the original UPayload. It would be better to separate them.
That is exactly what an application would need to do in case the response sent from the service contains an error, wouldn't it?
Do you mean we don't keep the origin UPayload and swap it with UStatus? I'm still not clear about how to put the original UPayload and UStatus together.
As part of implementing the L2 RpcClient we have removed the UListener::on_error function which does not serve any purpose (anymore). See d49ee8e8e202a0f23579d33bfae36da699e7fd4b
Currently
UListener::on_error(UStatus)
only provides error details in theUStatus
struct but does not provide any information regarding the context in which the error occurred.It seems reasonable to either pass in a full
UMessage
with theUStatus
as payload or instead pass in bothUStatus
andUAttributes
.