-
Notifications
You must be signed in to change notification settings - Fork 85
Updated workflow function to return Payload instead of empty tuple #542
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
Conversation
Thanks! Per my comment in #540 I think I'd prefer it if we went straight to the more general abstraction here 😄 |
Sure, I will work towards updating this. |
Hi @Sushisource, I am actually scratching my head to understand why you are asking for the Payload abstraction. 😁 I designed the workflow module to make sure that we can return any type as long as it implements Indeed I just postponed implementing the Payload converter as well in the workflow module. The thing is in all the tests, Workflow functions are created manually using I just need to update the |
d73f420
to
a1156a6
Compare
I'm a bit confused - very few of the tests (3 by my count) directly use What you have looks good to me now in terms of not touching many files - the main reason to introduce an abstraction is the So for now we could do that, just make the bounds here be Eventually |
let _ = "panic".parse::<i32>().unwrap(); | ||
Ok(().into()) |
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 test needs to stay as a panic, it's important to the goal of the test. You'll have to just add a type hint for the closure's return 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.
Type inference won't work and the code becomes unreachable after panic!()
. So panicking with unwrap
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.
Ah right, I missed the unwrap - regardless this can keep the more obvious panic by providing an explicit return type for the closure.
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.
Fixed
I tried a lot to replace 'Payload' in the Workflow Future with a trait before starting the discussion 😄. Regarding the Payload being generic. I changed the trait a bit for now here, next PR. I think we need to pass the Payload converter into both WfContext and ActContext and use it in a wrapper function like this. I will work on how we can make this dynamic without help from the generics. Currently looks like this let activity = ActivityOptions {
activity_id: Some(activity_id.to_string()),
..Default::default()
};
let result = ctx.activity(activity).await.unwrap_ok_payload();
let result = String::from_payload(None, &result).expect("serializes fine");
Ok(WfExitValue::Normal(result))
} |
Though, the end result with wrapper functions the workflow looks like this, without any manual payload processing
|
Cool, for the purposes of this PR, I think just changing the bounds here be Serialize instead would be sufficient, and keeps things pretty much the same but without explicitly coupling things to JSON. As for the further generic-ification, I like what you have in your final example there, but I also want to avoid any explicit arity-based wrapper functions. More likely than not, I don't think we'll be merging anything that makes changes that substantial until we're prepared to really start investing in productionizing and supporting the Rust SDK. That said, your interest has been great, and in the spirit of us being transparent I'm going to make some time to at least publish a proposal outlining the direction I want to go with the Rust SDK, even though we still may not actually invest in the implementation immediately. |
Hi, The multiple arity functions are just wrappers in my code. They will not be in the SDK. But I would need the possibility of passing For example, the SDK will only have 0 or 1 argument function wrappers as you mentioned in the previous comment here. But my code is like Itertools for Iterators :) |
Thanks for deciding to spend time on the proposal 😄 . I can use that for direction instead. |
a1156a6
to
d5661a5
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.
Sweet, thanks!
What was changed
Why?
A step towards #222
Checklist
This part of work in [Feature Request] Workflow definitions #539
How was this tested:
Updated tests and added new tests
Any docs updates needed?
No