Skip to content

A gRPC Kotlin based server and client starter that builds with Gradle and runs on the JVM

License

Notifications You must be signed in to change notification settings

hwslabs/grpc-kotlin-starter

Repository files navigation

gRPC Kotlin starter

Overview

This directory contains a simple bar service written as a Kotlin gRPC example. You can find detailed instructions for building and running example from below

File organization

The starter sources are organized into the following top-level folders:

  • protos: .proto files for generating the stubs
  • stub: regular Java & Kotlin stub artifacts from protos
  • server: Kotlin servers based on regular stub artifacts
  • client: Kotlin clients based on regular stub artifacts

Set up and run the starter on macOS

  • Install Homebrew

    Download and install Homebrew:

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Install JDK

    Install any version of JDK (8 preferred):

    brew install openjdk@8

    Add the installed version of JDK to your path through .zshrc or .bash_profile

    echo 'export PATH="/usr/local/opt/openjdk@8/bin:$PATH"' >> ~/.zshrc
    source ~/.zshrc

    or

    echo 'export PATH="/usr/local/opt/openjdk@8/bin:$PATH"' >> ~/.bash_profile
    source ~/.bash_profile
  • Clone the project and run the bar service and client starter

    Clone and navigate into the project:

    git clone https://github.com/hwslabs/grpc-kotlin-starter.git
    cd grpc-kotlin-starter

    Start the server:

    ./gradlew :server:BarServer

    If you wish to start the server on a docker container (assuming you have docker installed on your machine)

    docker-compose up

    This will start the server and open up the 50051 port for connections

    In another console, run the client which will make requests to the server:

    ./gradlew :client:BarClient