-
Notifications
You must be signed in to change notification settings - Fork 76
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
Cadence signal blog #157
base: master
Are you sure you want to change the base?
Cadence signal blog #157
Conversation
--- | ||
title: Introduction to Cadence Signals | ||
|
||
date: 2023-08-06 |
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.
It would be good to move the date to be in September otherwise it wont come up at the top of the list when it is published.
authorlink: https://www.linkedin.com/in/chrisqin0610/ | ||
--- | ||
|
||
In this blog, we will have a brief overview of Cadence signals, a critical feature that provides a way to directly send data to a running workflow. |
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.
Some suggested changes
-
In this blog we will give you a brief overview.....
-
It would be good to highlight Cadence Signals in quotes, italics or bold as you are defining what it is.
|
||
In this blog, we will have a brief overview of Cadence signals, a critical feature that provides a way to directly send data to a running workflow. | ||
|
||
In previous blogs, we have gone through on how to implement a simple HelloWorld workflow, which takes a single string as workflow input and executes another activity to obtain the output. In that, you’ve learned two options to pass data to a workflow |
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.
Some suggested changes
-
In previous blogs, we have covered how to....
-
In that example, you learned about two options of how to pass data to a workflow
* Via start parameters | ||
* From return values of activities | ||
|
||
There are some limitations on these two options. For start parameters, it can only be passed before workflow execution begins. After the execution is kicked off, there is no way for us to change the input parameters. For activity return values, we can not directly pass value to them. They may come from another third party application at runtime. |
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.
A suggested change
- There are some limitations to these two options. Start parameters can only be passed ...
|
||
Therefore, we will need a way to interact with the workflow without changing the input parameters or manipulating with activity return values, which may introduce unexpected complications. With Cadence signals, you may provide data asynchronously to your running workflow. | ||
|
||
Using signals is very straightforward. In general, you just need to specify the type definition of your signal payload and the name of your signal. In the following example, the workflow first takes a single input parameter name. Then it keeps listening to a signal called greeting to which you should pass your payload. |
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.
maybe highlight the word 'greeting'
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.
Have added some minor suggestions to improve readability. Thanks
|
||
Then run the following command to pass a greeting message to this running workflow. | ||
```bash | ||
cadence --env development --domain cadence-samples-domain workflow signal --workflow_id test_id_1 --name greeting --input '"Hello"' |
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.
recommend we use more explicit plain JSON if possible, rather than JSON strings if possible. This is a real trap for new users who don't realise it's valid JSON encoding and get confused with the quotes.
ie:
--input '{"message": "hello"}'
where the value is being deserialised in the signal is a normal struct
type sampleMessage struct {
Message string // important trap here is the capitalization, this needs to be JSON serializable, so just providing an example here might help the poor and confused (like my past-self)
}
/// .. inside the workflow
var greeting sampleMessage
c.Receive(ctx, &greeting)
No description provided.