Skip to content

Commit 0ec3a12

Browse files
committed
microservice example readme done
1 parent eb7c20e commit 0ec3a12

3 files changed

Lines changed: 22 additions & 57 deletions

File tree

24.8 KB
Loading

examples_new/microservices/README.md

Lines changed: 22 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## Purpose
44

5-
An example microservices application for testing the [Chronos App](https://github.com/open-source-labs/Chronos). The [Chronos NPM package](https://www.npmjs.com/package/@chronosmicro/tracker) is installed and configured in each service to track metrics on communcation between services such as request and response cycles. Below are instructions for demo-ing Chronos with this example application.
5+
An example microservices application for testing the [Chronos App](https://github.com/open-source-labs/Chronos). The [Chronos NPM package](https://www.npmjs.com/package/@chronosmicro/tracker) is installed and configured in each service to track metrics on communcation between services such as request and response cycles. Below are instructions for demo-ing Chronos functionality.
66

77
## Design
88

@@ -23,56 +23,51 @@ The application functionality includes:
2323
- creating items
2424
- adjustment of item inventories
2525
- creating orders
26-
- throwing a 404 error - sending request to non-existent route
26+
- throwing an intentional 404 error - sending a request to a non-existent route
2727

2828
The Chronos NPM package is configured to track these request / response cycles.
2929

30-
The Event Bus serves as the intermediary between the backend services, facilitating communication by emitting and receiving numerous types of events and relaying them from one service to another. [review]
30+
Chronos is instantiated and its tracking functionality enabled by the following code block, found in each service's app.ts file.
3131

32-
The Event Bus facilitates communication between the backend services. [review]
32+
<img src="../../assets/example-microservices-tracker.png" alt="Chronos" title="Chronos" align="center" />\
3333

34-
Additionally, there is a common folder and a client-dev folder. In common, there can be found both a src and build folder. src contains (in Typescript) files common to each of the microservices. The related folder, build, will contain, after having run the scripts detailed in the package.json file, the resultant compiled Javascript files to be used by the corresponding services.
34+
The Event Bus serves as the intermediary between the backend services, facilitating communication between them. It receives and emits events whenever a resource is created.
3535

36-
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.
37-
38-
## Additional Documentation
39-
40-
For additional information on how Chronos works this example, please review the microservices section in the [Chronos NPM Package README](../../chronos_npm_package/README.md).
36+
The common folder maintains code snippets used across each microservice, and is distributed by way of a common NPM package.
4137

4238
## To Set Up Database for Storing/Retrieving Metrics
39+
## Database and .env setup
4340

44-
Create a single .env file in the _examples/microservices_ folder with the following key/value pairs:
41+
A `sample.env` file, located in the `examples/microservices` folder, has been provided with the necessary enivronmental variables to spin-up the application.
42+
43+
Create your own `.env` file in the `examples/microservices` folder with the following key/value pairs:
4544

4645
- `CHRONOS_DB`: `MongoDB` or `PostgreSQL`
47-
- `CHRONOS_URI`: The URI to the desired MongoDB or PostgreSQL database to save health metrics via **Chronos NPM Package**
46+
- `CHRONOS_URI`: The URI to the desired MongoDB or PostgreSQL database where the **Chronos NPM Package** will store recorded metrics. The **Chronos desktop application** retrieves and displays metrics from this database
4847
- `MONGO_URI_AUTH`: A **MongoDB** URI for the `auth` microservice to use
4948
- `MONGO_URI_ITEMS`: A **MongoDB** URI for the `items` microservice to use
5049
- `MONGO_URI_INVENTORY`: A **MongoDB** URI for the `inventory` microservice to use
5150
- `MONGO_URI_ORDERS`: A **MongoDB** URI for the `orders` microservice to use
52-
- `MONGO_URI_CLIENT`: A **MongoDB** URI for the `client` microservice to use
53-
- `JWT_KEY`: A random string used to sign and and verify JSON Web Tokens used by the auth service - the random string provided in **sample.env** will work
54-
- `JWT_LIFETIME`: The time-to-expiration of the JSON Web Token used by the auth service - this is set to **"1d"** in **sample.env** meaning user authentication is valid for 1 day
51+
- `JWT_KEY`: A random string used to sign and verify JSON Web Tokens used by the auth service - the random string provided in **sample.env** will work
52+
- `JWT_LIFETIME`: The time-to-expiration of the JSON Web Token used by the auth service - this is set to `1d` in `sample.env` meaning user authentication is valid for 1 day
5553

56-
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.
54+
Note: 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 manually deleting the collection from the database regularly using a UI such as MongoDB Compass.
5755

5856
## Start the Microservices
5957

60-
Peform the following steps in each of the _books_, _customers_, _orders_, and _reverse_proxy_ directories
61-
62-
1. `cd` into the folder
63-
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).
64-
3. Run `npm install`
65-
4. Run `npm run start`
58+
To spin up the example application:
6659

67-
**Mac Users:** Alternative to the above list of steps, `cd` into the `scripts` folder and run the `startMicroservices.sh` script
60+
1. `cd` into the `examples/microservices` folder
61+
2. Run `npm run pkg:install` to install all necessary dependencies
62+
3. Run `npm start`
6863

69-
#
64+
Open a web browser to `localhost:5000` to send requests from the client
7065

71-
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.
66+
Your microservice health metrics may be viewed in the given `CHRONOS_URI` database, or in the Electron.js desktop application.
7267

73-
Your microservice health metrics can now be viewed in the given `CHRONOS_URI` database, or, preferrably, in the Electron.js desktop application.
68+
## Additional Documentation
7469

75-
#
70+
For additional information on how Chronos works this example, please review the microservices section in the [Chronos NPM Package README](../../chronos_npm_package/README.md).
7671

7772
## Contributing
7873

examples_new/microservices/README.outline.md

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)