Skip to content
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

Add grpc samples #65

Merged
merged 4 commits into from
Dec 6, 2023
Merged

Add grpc samples #65

merged 4 commits into from
Dec 6, 2023

Conversation

qu1queee
Copy link
Member

Introduce grpc directory, containing a microservice architecture consisting of an internal grpc server, and a public client/server app.

A run.sh script is provided, to easily deploy this architecture in Code Engine, as well as a README, explaining the ideas behind.

@qu1queee qu1queee force-pushed the qu1queee/grpc branch 2 times, most recently from c22aa20 to adfab6d Compare December 4, 2023 16:05
Copy link
Collaborator

@reggeenr reggeenr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @qu1queee , thank you for putting together this sample! Looking forward to get it in finally. I do have a few comments mainly related to the run script, which I would like to discuss with you.

Next, I suggest that we plan a pairing session.

Best regards, Rico

grpc/run.sh Outdated Show resolved Hide resolved
grpc/run.sh Outdated
@@ -0,0 +1,31 @@
#!/bin/bash

set -euo pipefail
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to allow it being executed as part of test automation and to prevent users from having components being installed that incur costs, without the users understanding the full impact of them running the script, we'll need to add a cleanup routine to this script. See https://github.com/IBM/CodeEngine/blob/main/function2job/run for an example.

grpc/client/main.go Outdated Show resolved Hide resolved
fmt.Printf("using local endpoint: %s\n", localEndpoint)
conn, err := grpc.Dial(localEndpoint, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("failed to connect: %v", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we and stop the app initialization at this point?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log.Fatalf comes with an os.Exit(1)

grpc/Dockerfile.client Outdated Show resolved Hide resolved
grpc/Dockerfile.server Outdated Show resolved Hide resolved
grpc/Dockerfile.server Outdated Show resolved Hide resolved
Check the source code if you want to understand how this works. In general,
we provided three directories:

- `/ecommerce` directory hosts the protobuf files and declares the `grocery`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there every a need to regenerate this directory (e.g. after user made some adjustments to play around)? If so, I suggest to add the command to re-generate the files.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. Added a new script call `./regenerate-grpc-code.sh

grpc/README.md Outdated Show resolved Hide resolved
grpc/run.sh Outdated

# Buy an item from electronics and pay with 2000
echo "[INFO] Going to buy an iphone"
curl -q "${URL}"/buygrocery/electronics/iphone/2000.0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to add a command that checks whether the buy operation actually succeeded. If it doesn't we should end the script with exit code non-zero

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

covered

@qu1queee qu1queee force-pushed the qu1queee/grpc branch 2 times, most recently from 5e6b323 to 5a0cc98 Compare December 5, 2023 17:36
@qu1queee qu1queee marked this pull request as ready for review December 5, 2023 17:36
@qu1queee qu1queee requested a review from reggeenr December 5, 2023 17:36
@qu1queee
Copy link
Member Author

qu1queee commented Dec 5, 2023

@reggeenr thanks for the review. I addressed all your comments. In addition, I added the following:

  • A build script for pushing the container images of the client and server
  • An architecture diagram in the README for this sample app

Introduce grpc directory, containing a microservice architecture
consisting of an internal grpc server, and a public client/server app.

A run.sh script is provided, to easily deploy this architecture in
Code Engine, as well as a README, explaining the ideas behind.

Signed-off-by: Mahesh Kumawat <[email protected]>
Signed-off-by: encalada <[email protected]>
Signed-off-by: Mahesh Kumawat <[email protected]>
Addressing all good feedback, to inline with other CE samples.

Signed-off-by: encalada <[email protected]>
@qu1queee qu1queee force-pushed the qu1queee/grpc branch 2 times, most recently from 5466c75 to bd6d33c Compare December 5, 2023 17:58
reggeenr
reggeenr previously approved these changes Dec 5, 2023
Copy link
Collaborator

@reggeenr reggeenr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - Great job, @qu1queee ! Appreciate the work you put in to finish this sample.

- Add architecture diagram to readme
- Refactor proto interface, to inline fields
- Add build script
- Recompile proto files

Signed-off-by: encalada <[email protected]>
Copy link
Collaborator

@reggeenr reggeenr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job. LGTM!!!

@reggeenr reggeenr merged commit e41e889 into IBM:main Dec 6, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants