Files
opencloud/pkg/server/grpc/server.go
David Christofas 630e2120e5 pass around the correct logger to the services
Also did some minor refactoring to make the code similar to the other
services.

Implements one task of owncloud/product#86

Signed-off-by: David Christofas <dchristofas@owncloud.com>
2020-06-23 17:29:28 +02:00

35 lines
961 B
Go

package grpc
import (
"github.com/owncloud/ocis-accounts/pkg/proto/v0"
svc "github.com/owncloud/ocis-accounts/pkg/service/v0"
"github.com/owncloud/ocis-pkg/v2/service/grpc"
)
// NewService initializes a new go-micro service ready to run
func NewService(opts ...Option) grpc.Service {
options := newOptions(opts...)
service := grpc.NewService(
grpc.Name(options.Name),
grpc.Context(options.Context),
grpc.Address(options.Address),
grpc.Namespace(options.Namespace),
grpc.Logger(options.Logger),
grpc.Flags(options.Flags...),
)
var hdlr *svc.Service
var err error
if hdlr, err = svc.New(svc.Logger(options.Logger), svc.Config(options.Config)); err != nil {
options.Logger.Fatal().Err(err).Msg("could not initialize service handler")
}
if err = proto.RegisterAccountsServiceHandler(service.Server(), hdlr); err != nil {
options.Logger.Fatal().Err(err).Msg("could not register service handler")
}
service.Init()
return service
}