Skip to main content

gRPC Service

Usage​

Render from P6M Catalog​

archetect

P6M -> Java-> Java gRPC Service

Render from GitHub Repo​

archetect render git@github.com:p6m-archetypes/java-spring-boot-grpc-service-archetype.git

For information about interacting with the service, refer to the README at the generated project's root.

Prompts​

When rendering the archetype, you'll be prompted for the following values:

PropertyDescriptionExample
org-nameOrganization Nameafi, cpd, a1p
solution-nameSolution Nameapps, xyz
prefixGeneral name that represents the service domain that is used to set the entity, service, and RPC stub namesinvoice, order, booking
suffixUsed in conjunction with prefix to set package namesService, Adaptor, Orchestrator
persistenceDefines persistence. What database solution to useNone, CockroachDB

What's Inside​

This archetype is based on the SpringBoot framework and uses Maven as its build system.

Features include:

  • Out-of-the box endpoints, including /health, /info, /metrics, /env, /liquibase, and /threaddump.
  • Hibernate for ORM
  • Liquibase for changeset management
  • Simple CRUD over gRPC
  • gRPC stub publication based on the project name
  • Example GitLab CI configuration
  • Docker image publication to artifactory
  • Application configuration through property files, environment variables, and CLI arguments.
  • Integration with Tilt to support local k8s development
  • Out-of-the-box Postgres and LocalStack using Test Containers

Modules​

DirectoryDescription
{project-name}-apiService Interfaces with a gRPC model.
{project-name}-bomBill of Materials.
{project-name}-clientgRPC Client. Implements the API.
{project-name}-coreBusiness Logic. Abstracts Persistence, defines Transaction Boundaries. Implements the API.
{project-name}-grpcgRPC/Protobuf spec.
{project-name}-integration-testsLeverages the Client to test the Server and it's dependencies.
{project-name}-persistencePersistence Entities and Data Repositories. Wrapped by Core.
{project-name}-serverTransport/Protocol Host. Wraps Core.

Key Dependencies​

NameScopeDescription
gRPC Spring Boot StarterAPI/RemotingAuto-configures an embedded gRPC server integrated with Spring Boot
Spring Data JPAPersistenceORM.
AssertJUnit TestsFluent test assertions.
MockitoUnit TestsProvides mocking and spying functionality.
TestContainersUnit Tests, ContainersProgrammatic container management.
LocalStackProvides Docker images for common AWS services.