Giter Site home page Giter Site logo

nikos912000 / grpcdemo Goto Github PK

View Code? Open in Web Editor NEW
8.0 3.0 4.0 92 KB

Demo application for a Spring Boot service which exposes a gRPC endpoint. Built using Maven.

License: Apache License 2.0

Java 97.59% Dockerfile 0.88% Makefile 1.53%
grpc java spring-boot maven

grpcdemo's Introduction

gRPC Spring Boot Demo

Build Status License

Overview

Demo application for a Spring Boot service which exposes a gRPC endpoint. Built using Maven.

Installation

How to build

Make sure you have Java 17+ installed.

Compile and run unit tests:

./mvnw clean verify

Run integration tests:

./mvnw clean verify -Dskip.unitTests=true -Pfunctional-tests

How to run

Run on Intellij

You can run the app (i.e. com.nkatirtzis.grpcdemo.Application) on Intellij.

Run as a Spring Boot application

./mvnw spring-boot:run

Run the jar file

To run the jar file:

java -jar service/target/service-0.0.1-SNAPSHOT-exec.jar

Run in minikube

To run the application as a Docker container in a minikube cluster:

make minikube-build
minikube kubectl -- apply -f charts/install.yaml

Properties

Property Default value Description
grpc.port 6565 Port where gRPC server is running
spring.zipkin.enabled true Enables Zipkin for traces
spring.zipkin.baseUrl http://127.0.0.1:9411/ Host where trace data will be sent to. Need to be set if spring.zipkin.enabled is set to true.
spring.sleuth.sampler.probability 1 Configures the probability of spans exported. Value should be in range [0.0,1.0]

Usage

This app comes with server reflection enabled.

You can use a gRPC cmd tool such as grpc_cli or grpcurl to send requests to the app.

Health check

Check the server’s health status using grpc_cli:

grpc_cli call localhost:6565 Check ''

or using grpcurl:

grpcurl -plaintext -d '' localhost:6565 grpc.health.v1.Health/Check

Main endpoint

Hit the main endpoint using grpc_cli:

grpc_cli call localhost:6565 Reviews 'id:1'

or using grpcurl:

grpcurl -plaintext -d '{"id": 1}' localhost:6565 ReviewsService/GetReviews

Metrics

The app exposes an endpoint under /metrics where you can see a list of available metrics.

Traces

It has also been instrumented to report traces to Zipkin. To run Zipkin locally:

docker run -p 9411:9411 openzipkin/zipkin

Once you make gRPC request(s) to the app traces will be available on http://localhost:9411/zipkin/.

grpcdemo's People

Contributors

dependabot[bot] avatar nikos912000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.