Skip to content

takesection-sandbox/hello-akka-grpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Akka gRPC の例

1. 開始

asdf

Homebrew を使って asdf をインストールします。

brew install asdf

grpcurl

Homebrew を使って grpcurl をインストールします。

brew install grpcurl

Java

asdf を使って java をインストールします。

asdf plugin add java
asdf install java temurin-17.0.5+8

デフォルトでインストールしたバージョンの java が使用されるように設定します。

asdf global java temurin-17.0.5+8

sbt

asdf を使って sbt をインストールします。

asdf plugin add sbt
asdf install sbt 1.8.2

デフォルトでインストールしたバージョンの sbt が使用されるように設定します。

asdf global sbt 1.8.2

プロジェクトの生成

sbt を使ってプロジェクトを生成します。

sbt new sbt/scala-seed.g8

プロジェクト名は、ここでは hello-akka-grpc とします。

name [Scala Seed Project]: hello-akka-grpc

生成したプロジェクトをカレントディレクトリに設定します。

cd hello-akka-grpc

2. akka-grpc

Main.scala を IDE 等で実行します。

ターミナルから次のコマンドを実行してください。

grpcurl -plaintext localhost:8080 list

次のレスポンスが返ります。

com.pigumer.HelloService
grpc.reflection.v1alpha.ServerReflection

ターミナルから次のコマンドを実行してください。

grpcurl -plaintext localhost:8080 list com.pigumer.HelloService

次のレスポンスが返ります。

com.pigumer.HelloService.Hello

HelloService を実行します。

grpcurl -plaintext -d '{"name":"Foo"}' localhost:8080 com.pigumer.HelloService.Hello

次のレスポンスが返ります。

{
  "value": "Hello Foo"
}