Skip to content

Instantly share code, notes, and snippets.

View preslavmihaylov's full-sized avatar

Preslav Mihaylov preslavmihaylov

View GitHub Profile
version: '2.2'
services:
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.6.2
volumes:
- ./config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
healthcheck:
test: ["CMD", "curl", "-s", "-f", "http://localhost:9200/_cat/health"]
interval: 3s
git clone https://github.com/pmihaylovcom/go-elk-tutorial
package main
// imports
func main() {
fx.New(
bundlefx.Module,
fx.Invoke(httphandler.New),
).Run()
}
package bundlefx
// imports
func registerHooks(
lifecycle fx.Lifecycle,
logger *zap.SugaredLogger, cfg *configfx.Config, mux *http.ServeMux,
) {
lifecycle.Append(
fx.Hook{
package main
// imports
func main() {
fx.New(
configfx.Module,
loggerfx.Module,
httpfx.Module,
fx.Invoke(httphandler.New),
package httpfx
// imports
// Module provided to fx
var Module = fx.Options(
fx.Provide(http.NewServeMux),
)
...
func main() {
fx.New(
...
fx.Provide(http.NewServeMux),
...
).Run()
}
...
func main() {
fx.New(
configfx.Module,
loggerfx.Module,
...
).Run()
}
package loggerfx
// imports
// ProvideLogger to fx
func ProvideLogger() *zap.SugaredLogger {
logger, _ := zap.NewProduction()
slogger := logger.Sugar()
return slogger
...
// ProvideLogger to fx
func ProvideLogger() *zap.SugaredLogger {
logger, _ := zap.NewProduction()
slogger := logger.Sugar()
return slogger
}
func main() {