-
Notifications
You must be signed in to change notification settings - Fork 145
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
Enhancements to the Early Return sample #702
base: main
Are you sure you want to change the base?
Enhancements to the Early Return sample #702
Conversation
@@ -77,6 +77,7 @@ private static void runWorkflowWithUpdateWithStart(WorkflowClient client) { | |||
+ ")"); | |||
} catch (Exception e) { |
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.
@@ -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 comment
The 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 comment
The 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:
{
"transactionId": "TXID8524360451",
"status": "Initialization successful"
}
(the update mints a transaction id such as TXID8524360451)
And the workflow result is:
{
"transactionId": "TXID8524360451",
"status": "Transaction completed successfully."
}
@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 comment
The 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 TransactionConfirmation(transactionId, confirmationCode, ...)
and the workflow should return TransactionStatement(transactionId, finalAmount, ...)
. But yes, don't worry, I can make the changes, and I'll talk to @drewhoskins-temporal to de-naiveify the financial concepts.
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.
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 comment
The 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 comment
The 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.
What was changed
The Early Return sample in
core/src/main/java/io/temporal/samples/earlyreturn
Why?
Less failure-prone and easier to understand Early Return sample.
Checklist
n/a
Existing tests still apply
No