Home

Awesome

cqrs-demo

A demo application using the cqrs-es framework with a backing postgres repository.

Requirements

Alternatively, if a standard Postgres instance is running locally it can be utilized instead of the docker instance, see the init script for the expected table configuration.

Installation

Clone this repository

git clone https://github.com/serverlesstechnology/cqrs-demo

Enter the project folder and start a docker instance of PostgreSql

cd cqrs-demo
docker-compose up -d

Start the application

cargo run

Call the API, the easiest way to do this is to import the provided postman collection into your Postman client or the test_api.sh curl script found in the curl directory. Note that the command calls are configured to return a 204 status with no content, only the query call will return a 200 OK response with a body. For feedback on state you should call a query.

Docs you might want

Serverless cqrs-demo

A serverless demo is also available in this package. The bootstrap binary that is built may be run on AWS Lambda but requires a number of services to do so (e.g., IAM roles, database, etc.). For simplicity this demo will only be deployed in docker and tested locally, and will use the same database as before.

Additional Requirements

Building

Build a release version of the bootstrap binary targeting x86-MUSL and build this into a docker image using the provided Dockerfile.

cargo build --release \
  --target x86_64-unknown-linux-musl \
  --bin bootstrap
docker build -t cqrs-srvrls .

Ensure that the Postgres docker image is running, then start a new docker container using the created image.

docker run --rm --network=host cqrs-srvrls

Use the test_lambda.sh script in the curl directory to test the lambda container. The application is designed to be deployed using an AWS API Gateway proxy integration or Lambda Function URL. These use the v2.0 of the AWS Lamba proxy integration, more information on this format is available here.