Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: documenting persistent dev mode #1918

Merged
merged 5 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion docs/src/modules/java-protobuf/pages/running-locally.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,20 @@ grpcurl ^

== Shut down the service

Use `Ctrl+C` to shut down the service. When stopping your service, it will also shutdown the Kalix Runtime container and any other container you have defined in `docker-compose.yml`. Unless you have chosen to start `docker-compose` manually in a separate terminal, in which case you will need to stop it manually as well.
Use `Ctrl+C` to shut down the service. When stopping your service, it will also shutdown the Kalix Runtime container and any other container you have defined in `docker-compose.yml`. Unless you have chosen to start `docker-compose` manually in a separate terminal, in which case you will need to stop it manually as well.

== Running service with persistence enabled

By default, Kalix services are configured to run with disabled persistence. This means that the Kalix Runtime will use an in-memory database to store the state of your service. This is useful for local development since it allows you to quickly start and stop your service without having to worry about cleaning up the database.

However, if you want to run your service with persistence enabled, you can do so by changing the `docker-compose` file as below.

[source, dockerfile, indent=0]
----
include::example$scala-protobuf-doc-snippets/docker-compose.yml[tag=persistence-mode]
----
<1> Maps local directory to the Kalix Runtime database directory `/var/kalix`.
<2> Sets `PERSISTENCE_ENABLED` env to `true`.

== Running multiple services locally

Expand Down
13 changes: 13 additions & 0 deletions docs/src/modules/java/pages/running-locally.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,19 @@ curl -XGET localhost:9000/customer/one

Use `Ctrl+C` to shut down the service. When stopping your service, it will also shutdown the Kalix Runtime container and any other container you have defined in `docker-compose.yml`. Unless you have chosen to start `docker-compose` manually in a separate terminal, in which case you will need to stop it manually as well.

== Running service with persistence enabled

By default, Kalix services are configured to run with disabled persistence. This means that the Kalix Runtime will use an in-memory database to store the state of your service. This is useful for local development since it allows you to quickly start and stop your service without having to worry about cleaning up the database.

However, if you want to run your service with persistence enabled, you can do so by changing the `docker-compose` file as below.

[source, dockerfile, indent=0]
----
include::example$java-spring-doc-snippets/docker-compose.yml[tag=persistence-mode]
----
<1> Maps local directory to the Kalix Runtime database directory `/var/kalix`.
<2> Sets `PERSISTENCE_ENABLED` env to `true`.

== Running multiple services locally

A typical Kalix application is composed of one or more services deployed to the same Kalix project. When deployed under the same Kalix project, two different services can make xref:component-and-service-calls.adoc[calls to each other] or xref:service-to-service.adoc[subscribe to each other's event streams] by simply using their logical names.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ services:
kalix-runtime:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we agree that the docker-compose change is ok, I will change all compose files in samples.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless in a specific sample we demonstrate something that needs persistence, I would not change all the sample compose files to include this. I think maybe in the archetype we can put this (we have other flags there as well) but on the samples I don't see much benefit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit biased because I was using this a lot the last few days, but for me, the benefit is that the config is there, I don't have to look for it in the docs and copy-paste some lines. It's just a matter of uncommenting and I'm ready to go.

image: gcr.io/kalix-public/kalix-runtime:1.1.27
container_name: java-protobuf-customer-registry-kafka-quickstart
# uncomment volumes when persistence is enabled
# volumes:
# - ./target/kalix:/var/kalix
ports:
- "9000:9000"
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
PERSISTENCE_ENABLED: "false" #when true uncomment volumes above
JAVA_TOOL_OPTIONS: >
-Dkalix.proxy.eventing.support=kafka
USER_FUNCTION_HOST: ${USER_FUNCTION_HOST:-host.docker.internal}
Expand Down
9 changes: 8 additions & 1 deletion samples/java-spring-doc-snippets/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@

# tag::persistence-mode[]
version: "3"
services:
kalix-runtime:
image: gcr.io/kalix-public/kalix-runtime:1.1.27
# uncomment volumes when persistence is enabled
volumes: # <1>
- ./target/kalix:/var/kalix
ports:
- "9000:9000"
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
PERSISTENCE_ENABLED: "true" # <2>
# end::persistence-mode[]
JAVA_TOOL_OPTIONS: >
-Dkalix.proxy.eventing.support=google-pubsub-emulator
# tag::persistence-mode[]
USER_FUNCTION_HOST: ${USER_FUNCTION_HOST:-host.docker.internal}
USER_FUNCTION_PORT: ${USER_FUNCTION_PORT:-8080}
# end::persistence-mode[]
PUBSUB_EMULATOR_HOST: gcloud-pubsub-emulator
# Comment to enable ACL check in dev-mode (see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls)
ACL_ENABLED: "false"
Expand Down
11 changes: 8 additions & 3 deletions samples/scala-protobuf-doc-snippets/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
# tag::persistence-mode[]
version: "3"
services:
kalix-runtime:
image: gcr.io/kalix-public/kalix-runtime:1.1.27
container_name: scala-protobuf-doc-snippets
depends_on:
- gcloud-pubsub-emulator
# uncomment volumes when persistence is enabled
volumes: # <1>
- ./target/kalix:/var/kalix
ports:
- "9000:9000"
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
PERSISTENCE_ENABLED: "true" # <2>
# end::persistence-mode[]
JAVA_TOOL_OPTIONS: >
-Dkalix.proxy.eventing.support=google-pubsub-emulator
# tag::persistence-mode[]
USER_FUNCTION_HOST: ${USER_FUNCTION_HOST:-host.docker.internal}
USER_FUNCTION_PORT: ${USER_FUNCTION_PORT:-8080}
# end::persistence-mode[]
# Comment to enable ACL check in dev-mode (see https://docs.kalix.io/services/using-acls.html#_local_development_with_acls)
ACL_ENABLED: "false"
# Uncomment to enable advanced view features locally (note: disabled in deployed services by default)
Expand Down