Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Latest commit

 

History

History
86 lines (64 loc) · 3.02 KB

README.adoc

File metadata and controls

86 lines (64 loc) · 3.02 KB

Go microservice framework

GitHub branch checks state GitHub go.mod Go version godoc reference blue GitHub tag (with filter) codecov Go Report Card

Possibilities:

  1. Running a gin based HTTP/REST server ( see config )

  2. Running a gRPC server with metrics for Prometheus (see config and options)

  3. Working with the database via GORM with support for database migration via Goose with the ability to specify migration files from the file system or via embed.FS

  4. Using the gocron task scheduler

  5. Different log output format based on Zap, depending on the launch environment - launch in container or not

  6. Getting settings via environment variables

Configuration files

  1. config.go

  2. db/config.go - more details in the db/README.adoc

To read the configuration from the environment, it is recommended to use the method ReadEnvConfig()

TODO

see TODO.adoc

Examples

Minimum code configuration to run
func main() {
	_ := NewServiceWithEnvironment(context.Background(), zap.NewProductionConfig()).Run()
}
Configuration with the transfer of migration scripts for database migration via Embedded FS
import "embed"

//go:embed folder/*.sql
var embedMigrations embed.FS

func main(){
	_ := NewServiceWithEnvironment(context.Background(), zap.NewProductionConfig()).
		InitDB(&embedMigrations).
		Run()
}

alternative:

import "embed"

//go:embed folder/*.sql
var embedMigrations embed.FS

func main(){
	srv := NewServiceWithEnvironment(context.Background(), zap.NewProductionConfig())
	gormDB := srv.GetGormWithEmbeddedMigrations(&embedMigrations)

	srv.Run()
}
Specifying custom metrics for Prometheus for gRPC server
import grpcPrometheus "github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus"

func main() {
	_ := NewServiceWithEnvironment(context.Background(), zap.NewProductionConfig()).
		InitGrpcServerMetrics(grpcPrometheus.WithServerHandlingTimeHistogram()).
		Run()
}