README
¶
Toggle
Toggle is a Feature-Flag application. It uses event-driven paradigm.
Owner
API
gRPC
The API can be seen in proto files (*.proto
) in directory proto.
RESTful JSON
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/
How to Run
- Read Prerequisites.
- Then, read How to Run.
Development Guide
- Read Prerequisites.
- Then, read Development Guide.
Code Map
- Read Code Map
Testing
Unit Test
$ make test.unit
Integration Test
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
Load Test
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
Observability
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.
SDK
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.
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
Package entity defines all structs that flow through all application layers.
|
Package entity defines all structs that flow through all application layers. |
internal
|
|
pkg
|
|
sdk/toggle
Package toggle provides client SDK to access all toggle's use cases.
|
Package toggle provides client SDK to access all toggle's use cases. |
proto
|
|
indrasaputra/toggle/v1
Package togglev1 is a reverse proxy.
|
Package togglev1 is a reverse proxy. |
Package service defines the business logic of the requirement.
|
Package service defines the business logic of the requirement. |
test
|
|
mock/messaging
Package mock_messaging is a generated GoMock package.
|
Package mock_messaging is a generated GoMock package. |
mock/pkg/sdk/toggle
Package mock_toggle is a generated GoMock package.
|
Package mock_toggle is a generated GoMock package. |
mock/repository
Package mock_repository is a generated GoMock package.
|
Package mock_repository is a generated GoMock package. |
mock/repository/postgres
Package mock_postgres is a generated GoMock package.
|
Package mock_postgres is a generated GoMock package. |
mock/server
Package mock_server is a generated GoMock package.
|
Package mock_server is a generated GoMock package. |
mock/service
Package mock_service is a generated GoMock package.
|
Package mock_service is a generated GoMock package. |