Infra is a set of go libraries to unify the way we write grpc servers, access various databases, etc.
go get github.com/pushwoosh/infraAll databases and brokers libraries have similar design: each library has NewContainer function that creates a container
that holds named connections to the database.
To create a new connection, call Connect method. To fetch a connection, call Get method.
Every such library also has an Init helper that replaces the initRedises/initGrpcs/... boilerplate
copy-pasted into every service main. It creates a container, connects all configured connections in a
background goroutine registered in the given wait group, and dies with log.Fatal on any failure:
wg := &sync.WaitGroup{}
var (
redises = infraredis.Init(wg, cfg.RedisConnections)
grpcs = infragrpcclient.Init(wg, cfg.GRPCConnections)
mongos = inframongo.Init(wg, config.AppName, cfg.MongoConnections)
)
wg.Wait()- Postgres - based on jackc/pgx
- Clickhouse
- MongoDB
- Redis - based on go-redis v9 driver
- RabbitMQ
- Apache Kafka - based on segmentio/kafka-go
- NATS
- HTTP - http server helpers
- gRPC - gRPC server utilities for creating gRPC servers and gRPC gateways
- gRPC middlewares - set of standard middlewares
- Info - server info endpoint. provides endpoints for k8s liveness and readiness probes, pprof, build info
- GRPC Client - has same interface as database and broker libraries
- Log - zap logger wrapper
- Netretry - retry lib for temporary network errors
- Must - helper function to panic on error
- Prometheus pushgateway client - client for pushgateway, mostly used in cronjobs
- Operator
- System - OS signal handler