This project is a prototype for microservice on Golang with all required dependencies
archaeopteryx
helps you to create service with gRPC, gRPC proxy for REST API and some editional features from the box.
All features can be found in the list
You can find example of project in the example
folder.
Service has configuration, bases on https://github.com/jinzhu/configor. Your application should reimplement config of server like:
import (
archaeopteryx_config "github.com/iakrevetkho/archaeopteryx/pkg/config"
)
type Config struct {
archaeopteryx_config.Config
}
Service has methods to create logger:
import (
"github.com/sirupsen/logrus"
archaeopteryx_config "github.com/iakrevetkho/archaeopteryx/logger"
)
func main(){
var log *logrus.Entry
log = logger.CreateLogger("main")
}
All messages will be formatted with component name to make easy search by this name:
All custom services should implements interface service_server
:
// IServiceServer - interface for services servers for archaeopteryx.
//
// All services should implements this interface
// to make possible archaeopteryx registrate services handlers in server
type IServiceServer interface {
// RegisterGrpc - HealthServiceServer's method to registrate gRPC service server handlers
RegisterGrpc(sr grpc.ServiceRegistrar) error
// RegisterGrpcProxy - HealthServiceServer's method to registrate gRPC proxy service server handlers
RegisterGrpcProxy(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
}
- health check bases on https://github.com/grpc/grpc/blob/master/doc/health-checking.md
- logger with logrus nested formatter (https://github.com/antonfisher/nested-logrus-formatter)
- logger writes data into the console and file, which is rotated with https://github.com/iakrevetkho/woodpecker
- config is inited bases on https://github.com/jinzhu/configor
- server is waiting terminate signals on run
make install
make generate
archaeopteryx
requires folder for log files.
To create it run:
sudo mkdir /var/log/archaeopteryx
sudo chown $USER /var/log/archaeopteryx
For unit tests use:
make test
For lint use:
make lint
For testing gRPC API use Kreya
Folder kreya
contains Kreya project for working with the project.
Also archaeopteryx
is compatible with gRPC reflection