Toggle is a Feature-Flag application. It uses event-driven paradigm.
The API can be seen in proto files (*.proto
) in directory proto.
The API can be seen via web using Stoplight Elements.
$ docker run -p 4000:80 indrasaputra/toggle-elements:latest
Then, visit http://localhost:4000
in browser.
If docker is not preferred, the API is automatically generated in OpenAPIv2 format when generating gRPC codes.
The generated files are stored in directory openapiv2 in JSON format (*.json
).
To see the RESTful API contract, do the following:
- Open the generated json file(s), such as toggle.swagger.json
- Copy the content
- Open https://editor.swagger.io/
- Paste the content in https://editor.swagger.io/
- Read Prerequisites.
- Then, read How to Run.
- Read Prerequisites.
- Then, read Development Guide.
- Read Code Map
$ make test.unit
godog is mandatory to perform integration test.
To run the integration test, make sure you already run the application successfully. Follow How to Run for the guideline. When application is running, then run command to execute integration test.
$ make test.integration
You can also set the server URL, in case your default server is not localhost.
$ SERVER_URL=http://toggle:8081/v1/toggles make test.integration
Running smoke test, load test, and stress test is encouraged to know the sanity, performance, and stability of the service. k6 is used as load test executor.
$ k6 run <path to script file>
e.g:
$ k6 run internal/script/loadtest/load_test.js
or use docker
$ make test.load
The application already emits necessary telemetry. If application's dependencies are run using docker compose, then monitoring is provided by default. Otherwise, you have to provide them. These are stacks used as monitoring system.
Monitoring | Stack | Address |
---|---|---|
Metrics | Prometheus | http://localhost:9090 |
Visualization | Grafana | http://localhost:3000 |
Tracing | Jaeger | http://localhost:16686 |
Job Queue | Asynqmon | http://localhost:3001 |
Log | Zap | Stdout |
Currently, tracing only works on gRPC server (handler), service/usecase, and redis. Postgres is not traced yet.
There is already an SDK to access Toggle. Currently, the SDK only supports Go. The SDK codes are located in this very repository. Visit Toggle SDK.