-
Notifications
You must be signed in to change notification settings - Fork 163
Enhancements to the Early Return sample #702
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
base: main
Are you sure you want to change the base?
Changes from all commits
02ff9ef
138a41d
c693a65
ef45d74
e05af76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,7 @@ public TxResult processTransaction(TransactionRequest txRequest) { | |
} catch (Exception e) { | ||
initError = e; | ||
} finally { | ||
initDone = true; | ||
initDone = true; // Will unblock the early-return returnInitResult method | ||
} | ||
|
||
if (initError != null) { | ||
|
@@ -60,13 +60,14 @@ public TxResult processTransaction(TransactionRequest txRequest) { | |
|
||
@Override | ||
public TxResult returnInitResult() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that the early return update should return a distinct result type from the workflow. In my samples I've been imagining that the early return type is a "confirmation" or "validation" of the transaction, whereas the final workflow result would be some sort of statement of the final outcome of the transaction (I'm not an expert in this domain, but perhaps the exact amount transferred is not known until a later stage, e.g. due to market fluctuations/exchange rates etc) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This PR is for some logging enhancements to an already-accepted sample. It sounds like we're going back to the drawing board somewhat on what the sample should do? For clarity, currently the outcome of the early-return is for example:
(the update mints a transaction id such as TXID8524360451) And the workflow result is:
@dandavison Please tell me how do better express the 'validation' vs 'final confirmation' step and I will look at making the changes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can leave them until a subsequent PR; we may still be making some adjustments to the API. I think one underlying issue is that the Go sample doesn't have a return type for the update. So yes, I think it would be clearest for users if the update and the workflow return distinct types, e.g. the update should return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Edit, made this reply before seeing the one you sent above, Dan. It sounds like if I introduce a new object e.g. TxInitiationResult and make it return some stuff that feels very "this has been successfully initialized!" and keep the TxResult object for the workflow result that would satisfy. I want to confirm this though, as I'm re-hashing a sample that was already accepted as-is and I'm trying to avoid endless churn on this. Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds good. I'll get confirmation and post back here in an hour or less. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Confirmed, @drewhoskins-temporal and I agree that distinct return types are desirable. But like I say, if you want to leave it then I can do it as I suspect there's going to be a tweak to the API coming soon. |
||
Workflow.await(() -> initDone); | ||
Workflow.await(() -> initDone); // Wait for the initialization step of the workflow to complete | ||
5B3A
|
||
if (initError != null) { | ||
log.info("Initialization failed."); | ||
throw Workflow.wrap(initError); | ||
} | ||
|
||
return new TxResult(tx.getId(), "Initialization successful"); | ||
return new TxResult( | ||
tx.getId(), "Initialization successful"); // Return the update result to the caller | ||
} | ||
} |
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.
in description you mention specific grpc exception (StatusRuntimeException)
here just general Exception is asumed its of that type. could add some type check and maybe show how different exceptions could be handled differently in client
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.
@tsurdilo I have provided a check for StatusRuntimeException and "ExecuteMultiOperation API is disabled" specifically (with advice). Please let me know if this is enough.