Quick Start
Clone the Project
Fetch the code:
mkdir github.com/microbus-io
cd github.com/microbus-io
git clone https://github.com/microbus-io/fabric
It is recommended to clone the code into a directory structure that mirrors the package structure.
Setup and Run the Development Environment
The Microbus
framework depends on a few third-party services:
- NATS is a hard requirement used as the communication transport between microservice
- Prometheus is an optional service that can be used to collect metrics from
Microbus
microservices
- Grafana is an optional service that can visualize metrics collected by Prometheus
- Jaeger is an optional service that can visualize distributed tracing spans
Use docker compose
from within the setup
directory to quickly install the above and set up the development environment.
cd setup
docker compose -f microbus.yaml -p microbus up
Docker Desktop should now show the microbus
application:
Note that using Docker is not mandatory. You can also install the dependencies manually.
Run the Examples
Run the example app:
cd main
go run main.go
It is necessary to set the working directory to main
so that the file main/config.yaml
can be located.
If you’re using Visual Studio Code, simply press F5
. The .vscode/launch.json
file includes a launch configuration for running main
.
Try the following URLs in your browser:
- http://localhost:8080/calculator.example/arithmetic?x=5&op=*&y=8
- http://localhost:8080/calculator.example/square?x=5
- http://localhost:8080/calculator.example/square?x=not-a-number
- http://localhost:8080/calculator.example/distance?p1.x=0&p1.y=0&p2.x=3&p2.y=4
- http://localhost:8080/hello.example/echo
- http://localhost:8080/hello.example/ping
- http://localhost:8080/hello.example/hello?name=Bella
- http://localhost:8080/hello.example/calculator
- http://localhost:8080/hello.example/bus.png
- http://localhost:8080/messaging.example/home
- http://localhost:8080/messaging.example/cache-store?key=foo&value=bar
- http://localhost:8080/messaging.example/cache-load?key=foo
- http://localhost:8080/browser.example/browse?url=example.com
- http://localhost:8080/directory.example/web-ui?method=POST&path=/persons&body=%7B%22firstName%22:%22Harry%22,%22lastName%22:%22Potter%22,%22email%22:%22hp@hogwarts.edu%22%7D (push submit to perform the POST request)
- http://localhost:8080/directory.example/persons
- http://localhost:8080/directory.example/persons/key/1
- http://localhost:8080/directory.example/web-ui?method=DELETE&path=/persons/key/1 (push submit to perform the DELETE request)
Feel free to experiment with different values for the query arguments.
To view the metrics collected by Prometheus, go to http://localhost:9090/graph. As an example, you may execute the query microbus_uptime_duration_seconds_total
.
To view the same metrics in Grafana dashboards, go to http://localhost:3000 and login using the credentials admin
:admin
.
To view the distributed traces in Jaeger, go to http://localhost:16686.
The Todo Tree extension is recommended for VS Code users.