https://github.com/indrasaputra/toggle
Feature Flag or Feature Toggle application built with Go and gRPC
https://github.com/indrasaputra/toggle
feature-flags feature-toggles go golang grpc grpc-go toggle
Last synced: 12 months ago
JSON representation
Feature Flag or Feature Toggle application built with Go and gRPC
- Host: GitHub
- URL: https://github.com/indrasaputra/toggle
- Owner: indrasaputra
- License: bsd-3-clause
- Created: 2021-05-26T00:05:28.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-06-13T12:21:34.000Z (almost 4 years ago)
- Last Synced: 2025-03-25T06:51:13.985Z (about 1 year ago)
- Topics: feature-flags, feature-toggles, go, golang, grpc, grpc-go, toggle
- Language: Go
- Homepage:
- Size: 334 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Toggle
[](https://goreportcard.com/report/github.com/indrasaputra/toggle)
[](https://github.com/indrasaputra/toggle/actions)
[](https://codecov.io/gh/indrasaputra/toggle)
[](https://codeclimate.com/github/indrasaputra/toggle/maintainability)
[](https://sonarcloud.io/dashboard?id=indrasaputra_toggle)
[](https://pkg.go.dev/github.com/indrasaputra/toggle)
[](https://github.com/pre-commit/pre-commit)
Toggle is a [Feature-Flag](https://martinfowler.com/articles/feature-toggles.html) application. It uses event-driven paradigm.
## Owner
[Indra Saputra](https://github.com/indrasaputra)
## API
### gRPC
The API can be seen in proto files (`*.proto`) in directory [proto](proto/indrasaputra/toggle/v1/toggle.proto).
### RESTful JSON
The API can be seen via web using [Stoplight Elements](https://stoplight.io/open-source/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](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](openapiv2/proto/indrasaputra/toggle/v1/toggle.swagger.json)
- Copy the content
- Open [https://editor.swagger.io/](https://editor.swagger.io/)
- Paste the content in [https://editor.swagger.io/](https://editor.swagger.io/)
## How to Run
- Read [Prerequisites](doc/PREREQUISITES.md).
- Then, read [How to Run](doc/HOW_TO_RUN.md).
## Development Guide
- Read [Prerequisites](doc/PREREQUISITES.md).
- Then, read [Development Guide](doc/DEVELOPMENT_GUIDE.md).
## Code Map
- Read [Code Map](doc/CODE_MAP.md)
## Testing
### Unit Test
```
$ make test.unit
```
### Integration Test
[godog](https://github.com/cucumber/godog/#install) is mandatory to perform integration test.
To run the integration test, make sure you already run the application successfully. Follow [How to Run](doc/HOW_TO_RUN.md) 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](https://k6.io/docs/) is used as load test executor.
```sh
$ k6 run
```
e.g:
```sh
$ k6 run internal/script/loadtest/load_test.js
```
or use docker
```sh
$ make test.load
```
## Observability
The application already emits necessary telemetry. If application's dependencies are run using [docker compose](doc/HOW_TO_RUN.md#docker), then monitoring is [provided by default](docker-compose.yaml). Otherwise, you have to provide them.
These are stacks used as monitoring system.
| Monitoring | Stack | Address |
| --- | --- | --- |
| Metrics | [Prometheus](https://prometheus.io/) | [http://localhost:9090](http://localhost:9090) |
| Visualization | [Grafana](https://grafana.com/) | [http://localhost:3000](http://localhost:3000) |
| Tracing | [Jaeger](https://www.jaegertracing.io/) | [http://localhost:16686](http://localhost:16686) |
| Job Queue | [Asynqmon](https://github.com/hibiken/asynqmon) | [http://localhost:3001](http://localhost:3001) |
| Log | [Zap](https://github.com/uber-go/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](pkg/sdk/toggle/client.go).