kit

module
v0.2.12 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2023 License: Apache-2.0

README

GOMAXHUB / kit

kit.jpg Friendly framework with high-performance and strong-extensibility for building micro-services.

Features

  • one and only logger uber.Zap, initialized and configured for production in stock
  • chi http server
  • optional grpc server (parallel and single mode)
  • optional profiling for server (fgprof, pprof)
  • optional after/before funcs
  • add any number of your goroutines to server easily (WithCustomGoroutines option)
  • autoinstrumented with prometheus metrics handler on 0.0.0.0:9090/metrics
  • can easily register any prometheus collectors with same-named option
  • just use promauto.* to register any metrics you like, it will work immediately
  • e2e mode for testing your service
  • enabled pyroscope auto-exporter

Environment variables to use

Name Description Example Default
KIT_SERVER_VERSION Server version(for logs) 0.0.1 0.0.0
KIT_GRACEFUL_SHUTDOWN Shutdown timeout 10s 5s
KIT_TRACING_JAEGER_HOST Jaeger host to export traces jaeger_host:4318 localhost:4318
KIT_METRICS_FGPROF Enable fgprof true false
KIT_METRICS_PPROF Enable pprof true false
KIT_DEBUG_HEADERS Prints in logs !all! headers of requests true false
KIT_METRICS_PYROSCOPE_HOST Set host of pyroscope http://localhost:4040 http://localhost:4040

Default configuration

Feature Host Notes
HTTP Server(chi) 0.0.0.0:8080
GRPC Server 0.0.0.0:8081
Default jaeger host localhost:4318
Default GRPC header application/grpc
Fgprof address 0.0.0.0:6060 /debug/fgprof
Pprof address 0.0.0.0:8080 /debug/pprof/*
Prometheus address 0.0.0.0:9090 /metrics
Pyroscope server address http://localhost:4040

E2E testing mode

  • set WithEndToEndTests option and provide path to e2e.yaml file
  • use flag -mode=e2e to run e2e tests with your binary
  • see example in examples/chi_with_e2e folder
  • if you don't set requests timeout, it will be 10s by default
  • default timeout before tests are run is 5s, it's time to give your server wake up and init all connections
  • Timeout, Headers, Body of requests are optional

Directories

Path Synopsis
examples
chi

Jump to

Keyboard shortcuts

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