loan-app

Designing

While designing your service it is useful to read designing services

Developing

This project has a bare-bones skeleton service ready to go, but in order to adapt and extend it, it may be useful to read up on developing services and in particular the Java section

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

When running a Kalix service locally, we need to have its companion Kalix Runtime running alongside it.

To start your service locally, run:

mvn kalix:runAll

This command will start your Kalix service and a companion Kalix Runtime as configured in docker-compose.yml file.

Note: if you're looking to use Google Pub/Sub, see comments inside docker-compose.yml on how to enable a Google Pub/Sub emulator that Kalix Runtime will connect to.

With both the Kalix Runtime and your service 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/io.kx.loanapp.CounterService/GetCurrentCounter -d '{"counterId": "foo"}'
The command handler for `GetCurrentCounter` is not implemented, yet

For example, using grpcurl:

> grpcurl -plaintext -d '{"counterId": "foo"}' localhost:9000 io.kx.loanapp.CounterService/GetCurrentCounter 
ERROR:
  Code: Unknown
  Message: The command handler for `GetCurrentCounter` is not implemented, yet

Note: The failure is to be expected if you have not yet provided an implementation of GetCurrentCounter in your entity.

Deploying

To deploy your service, install the kalix CLI as documented in Install Kalix 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 kalix:deploy which will package, publish your docker image, and deploy your service to Kalix, or by first packaging and publishing the docker image through mvn deploy and then deploying the image through the kalix CLI.