Replies: 5 comments 1 reply
-
You perceive the document generator and mail function as a single operation. I think you need to split that in 2 distinct operations and each operation is responsible for its own resiliency. I think the retry mechanism should be in the mail operation and not at the end of the chain in your match/ex branch. |
Beta Was this translation helpful? Give feedback.
-
@sircuri I'm not sure I think of them as a single operation, more as two operations that happen one after the other, which is why I was binding them together. That was only an example, it's not the only case where I would have this question. The main point of my question wasn't about the retry mechanism itself, more about detecting where the error occurred. Yes, splitting them into two separate operations would answer that as well, but imagine this was a workflow where it was a single operation, I'd still want to know which part of it failed. Thanks for the reply. Any further comments? |
Beta Was this translation helpful? Give feedback.
-
@MrYossu Maybe I'm missing something, but can't you just look at the |
Beta Was this translation helpful? Give feedback.
-
@louthy Thanks for the suggestion. I guess I can do it that way, but I was hoping for something a little neater. Is this the only way of doing it? Thanks again. |
Beta Was this translation helpful? Give feedback.
-
I cannot really pinpoint where your view on this issue feels wrong. You want to fire a chain of events and if something fails you want to restart the chain. But at that point you want start at a specific step. Maybe add some kind of transaction identifier to the chain, so each step knows if it has already performed that step and can skip it? |
Beta Was this translation helpful? Give feedback.
-
Suppose I have a set of methods, each of which return a
TryAsync<T>
, and I want to chain them together...This is all fine, but in the second lambda for
Match
, how do I know where the exception was thrown? Given that the various methods being called can throw a variety of exceptions, I can't rely on anticipating all possible exception types, and acting according to that, especially as more than one method might raise the same type of exception.The reason this is important is that I need to know where in the chain things broke, so I can retry the bits that broke, without repeating the bits that worked.
For example (ignoring the fact that I'm dealing with side-effects in my code, which I know I shouldn't be doing, but I'm still working all this out), then it could be that the first method generates a document and saves it to the database, and the second emails the document to someone. If the creation failed, I need to do the whole process again. However, if the creation succeeded, but the emailing failed, I don't want to generate a duplicate document, I just want to try emailing again.
Anyone any suggestions. Thanks.
Beta Was this translation helpful? Give feedback.
All reactions