Skip to content

Demonstrates MongoDB best practices for building resilient yet evolvable shared data applications, using Rust as an example

License

Notifications You must be signed in to change notification settings

mongodb-developer/mongo-resilient-evolvability-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongo-resilient-evolvability-demo

(by Paul Done - @TheDonester)

A project to demonstrate some of the best practices for building resilient yet evolvable shared data applications using a flexible data model based database like MongoDB. Based on the The Six Principles for Building Robust Yet Flexible Shared Data Applications.

For this example, uses a library books scenario where app1 is a books inventory management application exposed as a REST API and app2 is a books ratings/scores management application exposed as a REST API. These two apps operate on and require different overlapping subsets of attributes about each book. For the sake of simplicity, both apps are part of the same Rust Cargo project with a shared main bootstrap function, but when run each of the two apps listens on a different localhost HTTP port (8181 & 8282 respectively).

Building The Project

(ensure you've cloned/copied this GitHub project first to your local machine)

  1. Install the latest version of the Rust development environment, if it isn't already installed, via the rustup utility, including the rustc compiler & the cargo package/build manager. NOTE: If building on Windows 10, first ensure you have Microsoft's Build Tools for Visual Studio 2019 installed (and importantly, when running Microsoft's build tools installer, choose the C++ build tools option)

  2. From a terminal/prompt/shell, from this project's root folder, run Rust's cargo command to build the project, as shown below:

cargo build

Running The Project

(ensure you have the URL of an MongoDB database accessible, to enable the reading & writing of records in the database collection library.books)

  1. Load the book data into a MongoDB database using the MongoDB Shell (the example command shown assumes the database is listening on localhost:27017):
mongosh data/book-data-prep-for-app1.js
  1. To run the first application (listening for REST API calls), execute the following command (example URL shown assumes you are running a MongoDB single server unauthenticated database on your local machine listening on localhost:27017 - change this URL, containing appropriate credentials, to match the location of your remote MongoDB database):
cargo run app1 mongodb://localhost:27017
  1. From a browser test the first application's REST API Get operation:
  1. From a new terminal, run the first application's test script (tests retrieving all books + adding/modifying/removing a book via the app's REST API) by executing the following command:
tests/test_app1.sh
  1. Modify some of the book data to include some review scores in the MongoDB database using the MongoDB Shell (the example command shown assumes the database is listening on localhost:27017):
mongosh data/book-data-prep-for-app2.js
  1. To run the second application (listening for REST API calls), keep the existing first application running and in a new terminal execute the following command (change this URL to match the location of your remote MongoDB database):
cargo run app2 mongodb://localhost:27017
  1. From a browser test the second application's REST API Get operation:
  1. Run the second application's test script (tests adding/modifying/removing some book reviews via the app's REST API) by executing the following command:
tests/test_app2.sh

About

Demonstrates MongoDB best practices for building resilient yet evolvable shared data applications, using Rust as an example

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published