Skip to content

Feature Flag or Feature Toggle application built with Go and gRPC

License

Notifications You must be signed in to change notification settings

indrasaputra/toggle

Repository files navigation

Toggle

Go Report Card Workflow codecov Maintainability Quality Gate Status Go Reference pre-commit

Toggle is a Feature-Flag application. It uses event-driven paradigm.

Owner

Indra Saputra

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:

How to Run

Development Guide

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.