pekko-persistence-app
is an example project to show real usage of the Dump Persistence Schema Compiler Plugin.
This project uses logic from the pekko-microservices-tutorial
(the shopping-cart-service
), with Pekko Serialization Helper added.
You can test Dump Persistence Schema Compiler Plugin on this example project. There are two possibilities to do it:
sbt compile
- compiles the project with thedump-persistence-schema
phase enabled.dump-persistence-schema
phase dumps detected persistence schema (types for Events and States) into.json
files under thetarget/dump-psersistence-schema-cache
directory of this project. These.json
files are cache files used later by theashDumpPersistenceSchema
sbt task.sbt ashDumpPersistenceSchema
— sbt task that creates final output of the dump using mentioned.json
files. Output is saved into thetarget/pekko-persistence-app-dump-persistence-schema-0.1.0-SNAPSHOT.yaml
file. You can just invokesbt ashDumpPersistenceSchema
withoutsbt compile
—ashDumpPersistenceSchema
task will invokesbt compile
if needed.
-
Prepare docker containers with:
docker-compose up -d
-
Create database tables with:
docker exec -i pekko-persistence-app_postgres-db_1 psql -U shopping-cart -t < ddl-scripts/create_tables.sql`
-
Start a first node:
sbt "run local1.conf"
-
(Optional) Start another node with different ports:
sbt "run local2.conf"
-
(Optional) Check for service readiness:
curl http://localhost:9101/ready
-
Interact with the service using grpcurl - example request (put items in the cart):
grpcurl -d '{"cartId":"cart1", "itemId":"T-shirt", "quantity":3}' -plaintext 127.0.0.1:8101 shoppingcart.ShoppingCartService.AddItem
-
Dump persistence schema with Pekko Serialization Helper (after shutting down the application):
sbt ashDumpPersistenceSchema
Output saved into the target/pekko-persistence-app-dump-persistence-schema-0.1.0-SNAPSHOT.yaml
file.