Skip to content

Commit 95af2e8

Browse files
committed
Updated comments in the microservices example models.
Edited the startMicroservices script file. Updated the Microservices README.
1 parent ef600e0 commit 95af2e8

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

examples/microservices/README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,36 @@ Microservices architecture for testing [Chronos](https://github.com/open-source-
44

55
## Purpose and Design
66
This sample microservices architecture allows developers to explore the functionality of Chronos. It consists of four microservices, which are contained within the directories:
7-
- Reverse Proxy
8-
- Books
9-
- Customers
10-
- Orders
7+
- books
8+
- customers
9+
- orders
10+
- reverse_proxy
1111

1212
Each microservice has its own server, which receives requests from both the client and from other microservices. Books, Customers, and Orders also have their own databases, which they can query to respond to those requests.
1313

14-
## Steps to Run Example
15-
1. Create a single .env file in the *examples/microservices* folder with the following key/value pairs:
14+
## To Set Up Database for Storing/Retrieving Metrics
15+
Create a single .env file in the *examples/microservices* folder with the following key/value pairs:
1616
- `CHRONOS_DB`: `MongoDB` or `PostgreSQL`
17-
- `CHRONOS_URI`: The URI to the desired MongoDB or PostgreSQL database to save health metrics via **Chronos**
18-
- `BOOK_URI`: A **MongoDB** URI for the bookserver microservice to use
19-
- `CUSTOMER_URI`: A **MongoDB** URI for the customerserver microservice to use
20-
- `ORDER_URI`: A **MongoDB** URI for the orderserver microservice to use
17+
- `CHRONOS_URI`: The URI to the desired MongoDB or PostgreSQL database to save health metrics via **Chronos NPM Package**
18+
- `BOOK_URI`: A **MongoDB** URI for the `books` microservice to use
19+
- `CUSTOMER_URI`: A **MongoDB** URI for the `customers` microservice to use
20+
- `ORDER_URI`: A **MongoDB** URI for the `orders` microservice to use
2121

22+
Note: The `CHRONOS_URI` and all microservice `_URI`'s can be the same URI if you use MongoDB. You may run out of space in your database if the services run for an extended period of time. You can temporarily solve this by creating separate databases, or manually deleting the collection from the database regularly using a UI such as MongoDB Compass. When running, the microservices will create new collections if none are found in the database.
2223

23-
Peform the following steps in each of the *books*, *customers*, *orders*, and *reverse proxy* directories
24+
## Start the Microservices
25+
Peform the following steps in each of the *books*, *customers*, *orders*, and *reverse_proxy* directories
2426
1. `cd` into the folder
2527
2. Look at `package.json` to note where `@chronosmicro/tracker` is being imported from. Verify that it is coming from the desired location (whether the published remote from npm or from local directory).
2628
3. Run `npm install`
2729
4. Run `npm run start`
2830

31+
**Mac Users:** Alternative to the above list of steps, `cd` into the `scripts` folder and run the `startMicroservices.sh` script
32+
2933
#
30-
Then open a web browser to `localhost:3000` and verify that the simple webpage application is operational.
34+
Then open a web browser to `localhost:3000` and verify that the simple webpage application is operational. You can use the web app if you wish, but it is not necessary for retrieving and visualizing health metrics in Chronos.
3135

32-
Your microservice health metrics can now be viewed at the given `CHRONOS_URI` or, preferrably, in the Electron.js desktop application.
36+
Your microservice health metrics can now be viewed in the given `CHRONOS_URI` database, or, preferrably, in the Electron.js desktop application.
3337
#
3438

3539
## Contributing

examples/microservices/books/BookModel.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ require('dotenv').config({
66
const mongoose = require('mongoose');
77
const { Schema } = mongoose;
88

9-
// UNCOMMENT THE LINE BELOW AND REPLACE WITH AN ACTUAL MONGODB URI FOR YOUR "CUSTOMERS" DATABASE
10-
require('./chronos-config'); // Bring in config file
9+
require('./chronos-config');
10+
/**
11+
* Your .env file's BOOK_URI will be referenced here to connect the
12+
* `books` microservice metrics to your database.
13+
*/
1114
const myURI = process.env.BOOK_URI;
1215

1316
mongoose.connect(myURI, { useNewUrlParser: true, useUnifiedTopology: true })

examples/microservices/customers/CustomerModel.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ require('dotenv').config({
66
const mongoose = require('mongoose');
77
const { Schema } = mongoose;
88

9-
require('./chronos-config'); // Bring in config file
9+
require('./chronos-config');
10+
/**
11+
* Your .env file's CUSTOMER_URI will be referenced here to connect the
12+
* `customers` microservice metrics to your database.
13+
*/
1014
const myURI = process.env.CUSTOMER_URI;
1115

1216
mongoose.connect(myURI, { useNewUrlParser: true, useUnifiedTopology: true })

examples/microservices/orders/OrderModel.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ require('dotenv').config({
66
const mongoose = require('mongoose');
77
const { Schema } = mongoose;
88

9-
// UNCOMMENT THE LINE BELOW AND REPLACE WITH AN ACTUAL MONGODB URI FOR YOUR "ORDERS" DATABASE
10-
require('./chronos-config'); // Bring in config file
9+
require('./chronos-config');
10+
/**
11+
* Your .env file's ORDER_URI will be referenced here to connect the
12+
* `orders` microservice metrics to your database.
13+
*/
1114
const myURI = process.env.ORDER_URI;
12-
// const myURI = 'mongodb+srv://johndoe:[email protected]/';
1315

1416
mongoose.connect(myURI, { useNewUrlParser: true, useUnifiedTopology: true })
1517
.then(() => console.log('Connected!!!********* Order Database is live!!!'))
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
#!/bin/bash
22
cd ../books
33
dir=$(pwd)
4-
com="cd $dir && npm run start"
4+
com="cd $dir && npm install && npm run start"
55
echo $dir
66
osascript -e "tell app \"Terminal\" to do script \"$com\""
7+
78
cd ../customers
89
dir=`pwd`
9-
com="cd $dir && npm run start"
10+
com="cd $dir && npm install && npm run start"
1011
echo $dir
1112
osascript -e "tell app \"Terminal\" to do script \"$com\""
1213

1314
cd ../orders
1415
dir=$(pwd)
15-
com="cd $dir && npm run start"
16+
com="cd $dir && npm install && npm run start"
1617
echo $dir
1718
osascript -e "tell app \"Terminal\" to do script \"$com\""
1819

1920
cd ../reverse_proxy
2021
dir=$(pwd)
21-
com="cd $dir && npm run start"
22+
com="cd $dir && npm install && npm run start"
2223
echo $dir
2324
osascript -e "tell app \"Terminal\" to do script \"$com\""

0 commit comments

Comments
 (0)