mirror of
https://github.com/foomo/keel.git
synced 2025-10-16 12:35:34 +00:00
| .github/workflows | ||
| config | ||
| demo | ||
| env | ||
| examples/sessionid | ||
| log | ||
| metrics | ||
| net | ||
| telemetry | ||
| utils/net/http | ||
| .editorconfig | ||
| .gitignore | ||
| .golangci.yml | ||
| closer.go | ||
| go.mod | ||
| go.sum | ||
| ldflags.go | ||
| LICENSE | ||
| Makefile | ||
| option.go | ||
| README.md | ||
| server_test.go | ||
| server.go | ||
| service_http_prometheus.go | ||
| service_http_viper.go | ||
| service_http_zap.go | ||
| service_http.go | ||
| service.go | ||
keel
Opinionated way to run services.
Stack
- Metrics: Prometheus
- Logging: Zap
- Telemetry: Open Telemetry
- Configuration: Viper
Example
package main
import (
"net/http"
"os"
"github.com/foomo/keel"
"github.com/foomo/keel/log"
)
func main() {
svr := keel.NewServer()
l := svr.Logger()
// add zap service listening on localhost:9100
// allows you to view / change the log level: GET / PUT localhost:9100/log
svr.AddServices(keel.NewDefaultServiceHTTPZap())
// add viper service listening on localhost:9300
// allows you to view / change the configuration: GET / PUT localhost:9300/config
svr.AddServices(keel.NewDefaultServiceHTTPViper())
// add prometheus service listening on 0.0.0.0:9200
// allows you to collect prometheus metrics: GET 0.0.0.0:9200/metrics
svr.AddServices(keel.NewDefaultServiceHTTPPrometheus())
svr.AddService(
keel.NewServiceHTTP(log.WithServiceName(l, "demo"), ":8080", newService()),
)
svr.Run()
}
func newService() *http.ServeMux {
s := http.NewServeMux()
s.HandleFunc("/panic", func(w http.ResponseWriter, r *http.Request) {
panic("exiting")
})
s.HandleFunc("/exit", func(w http.ResponseWriter, r *http.Request) {
os.Exit(1)
})
return s
}
How to Contribute
Make a pull request...
License
Distributed under MIT License, please see license file within the code for more details.