Code Monkey home page Code Monkey logo

map-service-demo's Introduction

Quarkus gRPC Map Service

Overview

This project demonstrates a simple gRPC service using Quarkus, enabling clients to update and retrieve user positions on a map. It's designed as a backend service for applications that require real-time location tracking.

Setup

Requirements

  • Java JDK 11 or later
  • Maven 3.6.2 or later

Getting Started

  1. Clone the repository

    git clone [repository-url]
    cd map-service-demo
    
  2. Compile the project This step generates the gRPC service stubs from your .proto files.

    ./mvnw compile
    
  3. Run the application

    ./mvnw quarkus:dev
    

    The service will start on localhost with the default gRPC server port (9000).

Usage

Updating User Position

Clients can update their position by calling the UpdatePosition RPC method. Example using grpcurl:

grpcurl -plaintext -proto src/main/proto/map_service.proto -d '{"userId": "user1", "latitude": 50.1109, "longitude": 8.6821}' localhost:9000 mapservicedemo.MapService/UpdatePosition

Retrieving Positions

Clients can retrieve the positions of all users by calling the GetPositions RPC method.

grpcurl -plaintext -proto src/main/proto/map_service.proto -d '{}' localhost:9000 mapservicedemo.MapService/GetPositions

Project Structure

  • src/main/proto/map_service.proto: Contains the Protobuf definitions for the service and messages.
  • src/main/java/mapservicedemo/MapServiceImpl.java: The implementation of the gRPC service defined in the .proto file.
  • pom.xml: Maven project file with dependencies and plugin configurations needed to compile and run the service.

Running the application in dev mode

You can run your application in dev mode that enables live coding using:

./mvnw compile quarkus:dev

NOTE: Quarkus now ships with a Dev UI, which is available in dev mode only at http://localhost:8080/q/dev/.

Packaging and running the application

The application can be packaged using:

./mvnw package

It produces the quarkus-run.jar file in the target/quarkus-app/ directory. Be aware that it’s not an über-jar as the dependencies are copied into the target/quarkus-app/lib/ directory.

The application is now runnable using java -jar target/quarkus-app/quarkus-run.jar.

If you want to build an über-jar, execute the following command:

./mvnw package -Dquarkus.package.type=uber-jar

The application, packaged as an über-jar, is now runnable using java -jar target/*-runner.jar.

Creating a native executable

You can create a native executable using:

./mvnw package -Dnative

Or, if you don't have GraalVM installed, you can run the native executable build in a container using:

./mvnw package -Dnative -Dquarkus.native.container-build=true

You can then execute your native executable with: ./target/map-service-demo-1.0.0-SNAPSHOT-runner

If you want to learn more about building native executables, please consult https://quarkus.io/guides/maven-tooling.

Contributing

Contributions to the project are welcome. Please follow the standard fork and pull request workflow.

License

Apache License 2.0

map-service-demo's People

Contributors

scanalesespinoza avatar

Watchers

 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.