-
Notifications
You must be signed in to change notification settings - Fork 171
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
Added sagaexecutor example #489
Conversation
Sorry, somehow missed the extra parameter I asked on the NewService call in Poller as that logic hadn't been changed for a while & I must have been testing with an old image without noticing. |
Also, I just realised that the Tilt files I have used to build & deploy the components are configured for my RPi k3s cluster as I don't have a X86 one available for me to use. |
Amazing example, I really like this. Will definitely be useful for showcasing tilt given the push for an improvement in the developer experience. I think it'd be perfect if you could possibly convert the README.pdf to markdown and combine with the existing README.md? What would be even more brilliant is if we could get a validation test set up for this example too - mechanical markdown example go-sdk/examples/actor/README.md I know it's an example but I'd like to commit an improved docker build process - with scratch images. Can contribute and review with suggested changes when I have more bandwith. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #489 +/- ##
===========================================
- Coverage 70.08% 58.04% -12.04%
===========================================
Files 35 55 +20
Lines 2841 3568 +727
===========================================
+ Hits 1991 2071 +80
- Misses 738 1375 +637
- Partials 112 122 +10 ☔ View full report in Codecov by Sentry. |
Thanks. I have started on this and just committed to my repo the local set-up. I have written a script to automate the creation of the Postgres container & written a Dapr.yaml file to start the poller, a subscriber and the a test server. Next I will tackle the markup. When I boot up my proper dev machines again I will look for how I have previously created docker images from scratch. This will be a few years ago as I gave up on k8s a long time ago. |
Ok. I have completed the documentation consolidation. I can build a scratch image, but I can't figure out how to do that from Tilt. |
I have checked my image sizes and they are about 20Mb so I don't think moving to scratch is worth it? |
I have just included the latest changes I made, which was to remove my Postgres custom code & use the Dapr Postgres Binding instead. The only example for how to use this was in the Bindings test code ;-) Thus, this may be useful o others? |
OK. I have stopped making changes to this base code. Hopefully, it is ok now? |
examples/sagaexecutor/cmd/poller/app
Outdated
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.
Please do not include binary files.
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.
Done. Removed errant binary
@@ -0,0 +1,30 @@ | |||
# -*- mode: Python -*- |
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.
Please convert it to Makefile, which is more common.
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.
Not keen on doing that. However, ChatGPT makes that easily doable :-)
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.
Makefiles written (mostly) by ChatGPT, tweaked. Testing found issues but fixed & tested on Mac (M1 CPU) and tested build ok with AMD CPU
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.
Tested fixed makefiles on M2 Mac deployed to RPI k3s cluster & Intel Mac with Rancher desktop. All working as expected so I have finished the Makefiles addition request,
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]> Signed-off-by: stevef1uk <[email protected]>
Just tested on an intel system and realised the README was slightly wrong. Signed-off-by: stevef1uk <[email protected]> Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
…plus more simplifications Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Anyone got the time to finish review & merge? |
Yes i'll take a look at this today and early next week. |
A saga example in java was added to the quickstarts repo. I'm wondering if this would better be merged there. |
I can't see that but I did think about whether this should be in the QuickStarts but decided it wasn't a good fit as this is unashamably a Go project. |
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 it'd be amazing if you were able to add a git workflow to validate this example continuously
Sorry, that is something I usually leave to the DevOps team once the Cloud environments have been stood up ;-) |
Fair enough, I'm happy to pick that up as long as the example is working and we have an issue raised as a to-do at a later date. Will review when I get home 👀 |
Cool, although I don't want you to work extra hours. I just realised it has been over 24 years since I stopped being a professional programer. These days I do pretty much what I want and can get hands-on again. I have a new contract starting soon where I will have to learn Python. The last scripting language I used seriously was Perl so that dates me even more :-) Please let me know if the code doesn't work and I will fix it. I have only been able to test on Macs (Intel & M CPUs) and a couple of types of Kubernetes (Rancher & K3s) types. It worked for me :-) |
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.
First look review comments - I've reviewed without running the example:
This example involves a lot of steps which could potentially be added to a main makefile
at the root of the example. I don't see an issue with this example being committed in this way but should in the future be refactored with a few issues being raised for this to be completed at a later date.
I've not commented on the use of snake-case as a convention as this is a sample and is perfectly acceptable and valid.
The comments are a mix of spelling/corrections. A few things I've noticed are:
- Imports are currently referencing the repo
github.com/stevef1uk/sagaexecutor
which should be changed to that of this dapr repo (I've only noted this on thego.mod
but this affects each package where the import is made. - I potentially would like to see an env-var to specify the user's dockerhub/registry to push to which may reduce the amount of changes where
seahope
needs to be changed. - Some absolute paths are specified which should be updated to relative ones.
Looks great, with the minor tweaks it would be a great example to get people started with the saga pattern.
@@ -22,3 +22,5 @@ vendor | |||
# docs | |||
golang.org | |||
coverage.txt | |||
|
|||
.dapr |
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.
What is this new excludes for - can this be a change limited to that of the example folder for which this PR is made?
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.
What is this new excludes for - can this be a change limited to that of the example folder for which this PR is made?
This change was to stop the logs created when running locally from being committed to GitHub. I can delete the .gitignore from this directory though.
examples/sagaexecutor/LICENSE
Outdated
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 this licence file should be removed
examples/sagaexecutor/README.md
Outdated
2. The Saga Subscriber | ||
3. The Saga Poller | ||
|
||
The Saga components are shown in Green and the Dapr building blockes in Blue. |
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.
sp.
The Saga components are shown in Green and the Dapr building blockes in Blue. | |
The Saga components are shown in Green and the Dapr building blocks in Blue. |
examples/sagaexecutor/README.md
Outdated
### Prerequisites | ||
1. A kubernetes cluster is required with dapr installed (dapr init -k) | ||
2. Redis & Postgres must be installed on the cluster | ||
3. Tilt is is used to deply the components (see: https://tilt.dev). However, Makefiles are provided as well. Please note that these files |
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.
3. Tilt is is used to deply the components (see: https://tilt.dev). However, Makefiles are provided as well. Please note that these files | |
3. Tilt is is used to deploy the components (see: https://tilt.dev). However, Makefiles are provided as well. Please note that these files |
sp.
examples/sagaexecutor/README.md
Outdated
== APP - sagapoller == 2024/01/01 09:14:26 Returned 0 records | ||
``` | ||
|
||
You will need to manally delete the postgres container for a full clean-up. |
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.
You will need to manally delete the postgres container for a full clean-up. | |
You will need to manually delete the postgres container for a full clean-up. |
sp.
examples/sagaexecutor/go.mod
Outdated
@@ -0,0 +1,61 @@ | |||
module github.com/stevef1uk/sagaexecutor |
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 module definition needs to be updated along with any references from each package.
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 module definition needs to be updated along with any references from each package.
Replaced all github.com/stevef1uk/sagaexecutor to github.com/dapr/go-sdk/examples/sagaexecutor
"fmt" | ||
"net/http" | ||
|
||
//"fmt" |
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.
//"fmt" |
Unused comment
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.
Appears to be a duplicate spec that could be removed.
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 have deleted it, but it was there for my convenience as to run on k8s it needs to be edited,
version: v1 | ||
metadata: | ||
- name: secretsFile | ||
value: /Users/stevef/dev/sagaexecutor/components/secrets.json |
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 absolute path to the secrets file appears to be problematic for those attempting to use this. A change required to this file is not documented so I believe it should be relative.
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 absolute path to the secrets file appears to be problematic for those attempting to use this. A change required to this file is not documented so I believe it should be relative.
I will look at this later when I have recreated a K8s system to test it against.
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 absolute path to the secrets file appears to be problematic for those attempting to use this. A change required to this file is not documented so I believe it should be relative.
I will look at this later when I have recreated a K8s system to test it against.
This absolute path was required for local testing and relative paths wouldn't let me load the component. I have added some code to the setup local.sh file to update this hard path to the one required so that should now work for you.
/*pp_id string `json:"app_id"` | ||
Service string `json:"service"` | ||
Token string `json:"token"` | ||
callback_service string `json:"callback_service"` | ||
Params string `json:"params"` | ||
Timeout int `json:"timeout"` | ||
Event bool `json:"event"` | ||
LogTime time.Time `json:"logtime"`*/ |
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.
Is this comment required?
Ok. I use Tilt to deploy so I kept the Makefile minimal as daixiang0 asked for Makefiles, which I first used in 1987 and assumed were no longer a thing :-)
Agreed.
|
Signed-off-by: stevef1uk <[email protected]>
I have made a start and added a commit for most of the minor changes requested. I haven't tried to recompile after changing the imports yet. Update: I have compiled the code successfully. You will need to edit the replace in Go.mod for your location to try to build this before its is actually added to the GitHub repo and then that replace can be removed. |
Signed-off-by: stevef1uk <[email protected]>
Just added a commit to enable DockerHub Id to be configured in the Makefiles. Tested this on my repo ok. |
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
Signed-off-by: stevef1uk <[email protected]>
OK, all changes requested in the initial review (that I can see above) and have responded to have been addressed. I hope you can now build & test this locally? For changing the owning repo name for the docker container images simply set the DOCKER_ID environment variable to it. |
Signed-off-by: stevef1uk <[email protected]>
…ects stats Signed-off-by: stevef1uk <[email protected]>
Je vous attends encore. |
Signed-off-by: mikeee <[email protected]>
Please review and see if this project is a suitable example.