Skip to content
Snippets Groups Projects
Commit fe0f71e0 authored by Malte Bauch's avatar Malte Bauch
Browse files

Add missing sbi northbound files

parent b462e9dc
No related branches found
No related tags found
No related merge requests found
Pipeline #97687 failed
This commit is part of merge request !251. Comments created here will be created in the context of that merge request.
package client
import (
spb "code.fbi.h-da.de/danet/api/go/gosdn/southbound"
"google.golang.org/grpc"
)
// SbiClient returns a client for the gRPC SBI service. It takes
// the address of the gRPC endpoint and optional grpc.DialOption
// as argument
func SbiClient(addr string, opts ...grpc.DialOption) (spb.SbiServiceClient, error) {
conn, err := grpc.Dial(addr, opts...)
if err != nil {
return nil, err
}
return spb.NewSbiServiceClient(conn), nil
}
package server
import (
spb "code.fbi.h-da.de/danet/api/go/gosdn/southbound"
"code.fbi.h-da.de/danet/gosdn/metrics"
"code.fbi.h-da.de/danet/gosdn/store"
"github.com/google/uuid"
"github.com/prometheus/client_golang/prometheus"
)
type sbiServer struct {
spb.UnimplementedSbiServiceServer
}
func (s sbiServer) GetSchema(request *spb.GetSchemaRequest, stream spb.SbiService_GetSchemaServer) error {
labels := prometheus.Labels{"service": "pnd", "rpc": "get schema"}
start := metrics.StartHook(labels, grpcRequestsTotal)
defer metrics.FinishHook(labels, start, grpcRequestDurationSecondsTotal, grpcRequestDurationSeconds)
pid, err := uuid.Parse(request.Pid)
if err != nil {
return handleRPCError(labels, err)
}
sid, err := uuid.Parse(request.Sid)
if err != nil {
return handleRPCError(labels, err)
}
pnd, err := pndc.GetPND(pid)
if err != nil {
return handleRPCError(labels, err)
}
sbi, err := pnd.GetSBIs().(*store.SbiStore).GetSBI(sid)
if err != nil {
return handleRPCError(labels, err)
}
// TODO: only for testing; should be chunks of SchemaTree sent
payload := &spb.Payload{Chunk: sbi.SchemaTreeGzip()}
err = stream.Send(payload)
if err != nil {
return handleRPCError(labels, err)
}
return nil
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment