toggle

module
v0.0.0-...-58ae5d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2022 License: BSD-3-Clause

README

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.

Directories

Path Synopsis
cmd
server command
Package entity defines all structs that flow through all application layers.
Package entity defines all structs that flow through all application layers.
internal
app
Package app provides global variables related to the app.
Package app provides global variables related to the app.
builder
Package builder provides functionality to build the representative flows.
Package builder provides functionality to build the representative flows.
config
Package config provides connection with environment configuration.
Package config provides connection with environment configuration.
decorator/service
Package service decorates interface in service directory.
Package service decorates interface in service directory.
grpc-gateway/server
Package server provides HTTP/2 to HTTP/1.1 gateway server functionality.
Package server provides HTTP/2 to HTTP/1.1 gateway server functionality.
grpc/handler
Package handler provides the functionality of HTTP/2 gRPC handler.
Package handler provides the functionality of HTTP/2 gRPC handler.
grpc/interceptor
Package interceptor provides gRPC interceptor.
Package interceptor provides gRPC interceptor.
grpc/server
Package server provides HTTP/2 gRCP server functionality.
Package server provides HTTP/2 gRCP server functionality.
messaging
Package messaging provide functionality to implement message queue system.
Package messaging provide functionality to implement message queue system.
repository
Package repository provides real implementation of storing data.
Package repository provides real implementation of storing data.
repository/postgres
Package postgres provides real connection to the PostgreSQL.
Package postgres provides real connection to the PostgreSQL.
repository/redis
Package redis provides real connection to the Redis.
Package redis provides real connection to the Redis.
server
Package server provides high-level contract about server and also provides a manager to manage all servers.
Package server provides high-level contract about server and also provides a manager to manage all servers.
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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL