johanandren / recycling-machine

Kalix workshop reference project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

recycling-machine

Reference project showing the complete recycling-machine project from the Kalix workshop

Building

You can use Maven to build your project, which will also take care of generating code based on the .proto definitions:

mvn compile

Running Locally

In order to run your application locally, you must run the Kalix proxy. The included docker-compose file contains the configuration required to run the proxy for a locally running application. It also contains the configuration to start a local Google Pub/Sub emulator that the Kalix proxy will connect to. To start the proxy, run the following command from this directory:

docker-compose up

To start the application locally, the exec-maven-plugin is used. Use the following command:

mvn compile exec:exec

With both the proxy and your application running, any defined endpoints should be available at http://localhost:9000. In addition to the defined gRPC interface, each method has a corresponding HTTP endpoint. Unless configured otherwise (see Transcoding HTTP), this endpoint accepts POST requests at the path /[package].[entity name]/[method]. For example, using curl:

> curl -XPOST -H "Content-Type: application/json" localhost:9000/com.example.RecyclingMachine/RecycleCans -d '{"machineId": "machine-one", "cans": 4 }'

For example, using grpcurl:

> grpcurl -plaintext -d '{"machineId": "machine-one"}' localhost:9000 com.example.RecyclingMachine/GetMachineState 

Deploying

To deploy your service, install the kalix CLI as documented in Setting up a local development environment and configure a Docker Registry to upload your docker image to.

You will need to update the dockerImage property in the pom.xml and refer to Configuring registries for more information on how to make your docker image available to Kalix.

Finally, you use the kalix CLI to create a project as described in Create a new Project. Once you have a project you can deploy your service into the project either by using mvn deploy which will also conveniently package and publish your docker image prior to deployment, or by first packaging and publishing the docker image through mvn clean package docker:push -DskipTests and then deploying the image through the kalix CLI.

About

Kalix workshop reference project


Languages

Language:Java 100.0%