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

Adds remote-procedure-call via gRPC #3189

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CoderSleek
Copy link

  • Adds remote-procedure-call implementation in java via gRPC
  • updates pom.xml to include remote-procedure-call module
  • adds rpc communication via gRPC adding 2 micro-services cart-service and product-service
  • includes unit tests and integration test for both services
  • UML diagrams for both micro-services

Fixes #2680

Copy link

github-actions bot commented Feb 16, 2025

PR Summary

This PR implements remote procedure calls using gRPC in Java. It introduces two microservices, cart-service and product-service, which communicate via gRPC. The implementation includes unit and integration tests, along with UML diagrams.

Changes

File Summary
pom.xml The pom.xml file was modified to include the remote-procedure-call module, adding the necessary dependencies for gRPC and Protobuf.
remote-procedure-call/README.md This README file provides a comprehensive guide on how to implement gRPC in Java, using two microservices (product-service and cart-service) for an e-commerce simulation. It details the setup, implementation, and execution of the gRPC services.
remote-procedure-call/cart-service/etc/cart-service.urm.png New file: UML diagram for the cart-service microservice.
remote-procedure-call/cart-service/etc/cart-service.urm.puml New file: UML diagram for the cart-service microservice.
remote-procedure-call/cart-service/pom.xml New file: This pom.xml file configures the Maven project for the cart-service module, including dependencies and build settings.
remote-procedure-call/cart-service/src/main/java/com/iluwatar/rpc/cart/Main.java This Java class is the main entry point for the cart-service. It initializes the gRPC channel, creates a CartServiceImpl instance, and performs operations to fetch and update product quantities.
remote-procedure-call/cart-service/src/main/java/com/iluwatar/rpc/cart/model/ProductInCart.java New file: This Java class defines the ProductInCart model, representing a product in the shopping cart. It includes fields for id, name, type, price, and quantityToReduce.
remote-procedure-call/cart-service/src/main/java/com/iluwatar/rpc/cart/service/CartService.java New file: This Java interface defines the contract for the CartService, specifying methods for managing products in the cart, including fetching all products and reducing quantities.
remote-procedure-call/cart-service/src/main/java/com/iluwatar/rpc/cart/service/CartServiceImpl.java This Java class implements the CartService interface. It handles communication with the product-service via gRPC to fetch products and reduce their quantities.
remote-procedure-call/cart-service/src/main/resources/logback.xml New file: Logback configuration file for the cart-service.
remote-procedure-call/cart-service/src/test/java/com/iluwatar/rpc/cart/service/CartServiceImplIntegrationTest.java New file: Integration tests for CartServiceImpl, verifying interactions with the product-service.
remote-procedure-call/cart-service/src/test/java/com/iluwatar/rpc/cart/service/CartServiceImplTest.java New file: Unit tests for CartServiceImpl, focusing on individual method functionality and error handling.
remote-procedure-call/cart-service/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker New file: Mockito configuration file for the cart-service tests.
remote-procedure-call/etc/remote-procedure-call.urm.puml New file: UML diagram for the overall remote procedure call architecture.
remote-procedure-call/pom.xml This pom.xml file manages the dependencies and build configuration for the remote-procedure-call module, including gRPC and Protobuf plugins.
remote-procedure-call/product-service/etc/product-service.urm.png New file: UML diagram for the product-service microservice.
remote-procedure-call/product-service/etc/product-service.urm.puml New file: UML diagram for the product-service microservice.
remote-procedure-call/product-service/pom.xml New file: This pom.xml file configures the Maven project for the product-service module, including dependencies and build settings.
remote-procedure-call/product-service/src/main/java/com/iluwatar/rpc/product/Main.java This Java class is the main entry point for the product-service. It initializes mock product data and starts the gRPC server.
remote-procedure-call/product-service/src/main/java/com/iluwatar/rpc/product/mocks/ProductMocks.java New file: This Java class provides mock product data for testing and initialization purposes.
remote-procedure-call/product-service/src/main/java/com/iluwatar/rpc/product/model/Product.java New file: This Java class defines the Product model, representing a product with fields for id, name, type, price, and quantity.
remote-procedure-call/product-service/src/main/java/com/iluwatar/rpc/product/service/ProductService.java New file: This Java interface defines the contract for the ProductService, specifying methods for retrieving product information.
remote-procedure-call/product-service/src/main/java/com/iluwatar/rpc/product/service/ProductServiceGrpcImpl.java This Java class implements the gRPC service for product-service, handling requests to fetch all products and reduce product quantities.
remote-procedure-call/product-service/src/main/java/com/iluwatar/rpc/product/service/ProductServiceImpl.java This Java class implements the ProductService interface, providing methods to retrieve product information from an in-memory store.
remote-procedure-call/product-service/src/main/resources/logback.xml New file: Logback configuration file for the product-service.
remote-procedure-call/product-service/src/test/java/com/iluwatar/rpc/product/service/ProductServiceGrpcImplTest.java New file: Unit tests for ProductServiceGrpcImpl, focusing on gRPC request handling and response generation.
remote-procedure-call/product-service/src/test/java/com/iluwatar/rpc/product/service/ProductServiceImplTest.java New file: Unit tests for ProductServiceImpl, verifying the retrieval of product information from the in-memory store.
remote-procedure-call/product-service/src/test/java/com/iluwatar/rpc/product/service/ProductServiceIntegrationTest.java New file: Integration tests for ProductServiceGrpcImpl, verifying the functionality of the gRPC service.
remote-procedure-call/product-service/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker New file: Mockito configuration file for the product-service tests.
remote-procedure-call/proto/shopping.proto New file: This Protobuf file defines the gRPC service contract, specifying the methods and data structures for communication between the cart-service and product-service.

autogenerated by presubmit.ai

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

LGTM!

Review Summary

Commits Considered (1)
Files Processed (30)
  • pom.xml (1 hunk)
  • remote-procedure-call/README.md (1 hunk)
  • remote-procedure-call/cart-service/etc/cart-service.urm.png (0 hunks)
  • remote-procedure-call/cart-service/etc/cart-service.urm.puml (1 hunk)
  • remote-procedure-call/cart-service/pom.xml (1 hunk)
  • remote-procedure-call/cart-service/src/main/java/com/iluwatar/rpc/cart/Main.java (1 hunk)
  • remote-procedure-call/cart-service/src/main/java/com/iluwatar/rpc/cart/model/ProductInCart.java (1 hunk)
  • remote-procedure-call/cart-service/src/main/java/com/iluwatar/rpc/cart/service/CartService.java (1 hunk)
  • remote-procedure-call/cart-service/src/main/java/com/iluwatar/rpc/cart/service/CartServiceImpl.java (1 hunk)
  • remote-procedure-call/cart-service/src/main/resources/logback.xml (1 hunk)
  • remote-procedure-call/cart-service/src/test/java/com/iluwatar/rpc/cart/service/CartServiceImplIntegrationTest.java (1 hunk)
  • remote-procedure-call/cart-service/src/test/java/com/iluwatar/rpc/cart/service/CartServiceImplTest.java (1 hunk)
  • remote-procedure-call/cart-service/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker (1 hunk)
  • remote-procedure-call/etc/remote-procedure-call.urm.puml (1 hunk)
  • remote-procedure-call/pom.xml (1 hunk)
  • remote-procedure-call/product-service/etc/product-service.urm.png (0 hunks)
  • remote-procedure-call/product-service/etc/product-service.urm.puml (1 hunk)
  • remote-procedure-call/product-service/pom.xml (1 hunk)
  • remote-procedure-call/product-service/src/main/java/com/iluwatar/rpc/product/Main.java (1 hunk)
  • remote-procedure-call/product-service/src/main/java/com/iluwatar/rpc/product/mocks/ProductMocks.java (1 hunk)
  • remote-procedure-call/product-service/src/main/java/com/iluwatar/rpc/product/model/Product.java (1 hunk)
  • remote-procedure-call/product-service/src/main/java/com/iluwatar/rpc/product/service/ProductService.java (1 hunk)
  • remote-procedure-call/product-service/src/main/java/com/iluwatar/rpc/product/service/ProductServiceGrpcImpl.java (1 hunk)
  • remote-procedure-call/product-service/src/main/java/com/iluwatar/rpc/product/service/ProductServiceImpl.java (1 hunk)
  • remote-procedure-call/product-service/src/main/resources/logback.xml (1 hunk)
  • remote-procedure-call/product-service/src/test/java/com/iluwatar/rpc/product/service/ProductServiceGrpcImplTest.java (1 hunk)
  • remote-procedure-call/product-service/src/test/java/com/iluwatar/rpc/product/service/ProductServiceImplTest.java (1 hunk)
  • remote-procedure-call/product-service/src/test/java/com/iluwatar/rpc/product/service/ProductServiceIntegrationTest.java (1 hunk)
  • remote-procedure-call/product-service/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker (1 hunk)
  • remote-procedure-call/proto/shopping.proto (1 hunk)
Actionable Comments (0)
Skipped Comments (0)

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
79.4% Coverage on New Code (required ≥ 80%)
D Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

Microservice pattern: Remote procedure invocation
1 participant