This is example of calling gRPC API from Clojure.
To use gRPC from Clojure, we need to set up gRPC Java environment first. We can use Maven or Gradle for project set up. In this example, we use Gradle.
When gradle is not installed on your system, need to install it first.
- Linux
$ sudo apt install gradle
- Mac OS
$ brew install gradle
We use stripped version of gRPC Java Example build.gradle. Original bulid.gradle is located at here.
Proto file should be located in src/main/proto
. In this example, route_guide.proto
is
used.
Generate project with gradle.
$ gradle generateProto
Starting a Gradle Daemon (subsequent builds will be faster)
:extractIncludeProto
:extractProto
:generateProto NO-SOURCE
BUILD SUCCESSFUL
Total time: 11.012 secs
This will generate gRPC java stub under build
directory from route_guide.proto
.
To use Java and Clojure mixed-code, :java-source-paths
parameter to set up
project.clj
.
:java-source-paths ["build/generated/source/proto/main"]