Skip to content
Snippets Groups Projects
nbi.go 1.38 KiB
Newer Older
  • Learn to ignore specific revisions
  • Manuel Kieweg's avatar
    Manuel Kieweg committed
    package server
    
    import (
    
    André Sterba's avatar
    André Sterba committed
    	"code.fbi.h-da.de/danet/gosdn/controller/app"
    
    	"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkdomain"
    
    	rbacInterfaces "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac"
    	"code.fbi.h-da.de/danet/gosdn/controller/rbac"
    
    
    	"code.fbi.h-da.de/danet/gosdn/controller/metrics"
    
    Malte Bauch's avatar
    Malte Bauch committed
    	"github.com/prometheus/client_golang/prometheus"
    	log "github.com/sirupsen/logrus"
    	"google.golang.org/grpc/codes"
    	"google.golang.org/grpc/status"
    
    Manuel Kieweg's avatar
    Manuel Kieweg committed
    // NorthboundInterface is the representation of the
    // gRPC services used provided.
    type NorthboundInterface struct {
    
    	Pnd  *PndServer
    	Core *Core
    	Csbi *Csbi
    	Sbi  *SbiServer
    
    André Sterba's avatar
    André Sterba committed
    	App  *App
    
    Manuel Kieweg's avatar
    Manuel Kieweg committed
    }
    
    
    Manuel Kieweg's avatar
    Manuel Kieweg committed
    // NewNBI receives a PndStore and returns a new gRPC *NorthboundInterface
    
    André Sterba's avatar
    André Sterba committed
    func NewNBI(
    	pnds networkdomain.PndStore,
    	users rbacInterfaces.UserService,
    	roles rbacInterfaces.RoleService,
    	jwt rbac.JWTManager,
    	apps app.IService,
    ) *NorthboundInterface {
    
    Manuel Kieweg's avatar
    Manuel Kieweg committed
    	return &NorthboundInterface{
    
    		Pnd:  NewPndServer(pnds),
    		Core: NewCoreServer(pnds),
    		Csbi: NewCsbiServer(pnds),
    		Sbi:  NewSbiServer(pnds),
    		Auth: NewAuthServer(&jwt, users),
    		User: NewUserServer(&jwt, users),
    		Role: NewRoleServer(&jwt, roles),
    
    André Sterba's avatar
    André Sterba committed
    		App:  NewAppServer(apps),
    
    Malte Bauch's avatar
    Malte Bauch committed
    
    func handleRPCError(labels prometheus.Labels, err error) error {
    	log.Error(err)
    	return status.Errorf(codes.Aborted, "%v", metrics.HandleError(labels, err, grpcAPIErrorsTotal))
    }