1
0
forked from extern/smegmesh
smegmesh/pkg/robin/responder.go

31 lines
567 B
Go
Raw Normal View History

2023-09-29 16:00:20 +02:00
package robin
2023-09-20 00:50:44 +02:00
import (
2023-09-29 16:00:20 +02:00
"context"
2023-09-20 00:50:44 +02:00
"errors"
"github.com/tim-beatham/smegmesh/pkg/ctrlserver"
"github.com/tim-beatham/smegmesh/pkg/rpc"
2023-09-20 00:50:44 +02:00
)
type WgRpc struct {
2023-09-29 16:00:20 +02:00
rpc.UnimplementedMeshCtrlServerServer
Server *ctrlserver.MeshCtrlServer
2023-09-20 00:50:44 +02:00
}
func (m *WgRpc) GetMesh(ctx context.Context, request *rpc.GetMeshRequest) (*rpc.GetMeshReply, error) {
2023-10-06 12:52:51 +02:00
mesh := m.Server.MeshManager.GetMesh(request.MeshId)
2023-09-20 00:50:44 +02:00
2023-10-06 12:52:51 +02:00
if mesh == nil {
return nil, errors.New("mesh does not exist")
2023-09-20 00:50:44 +02:00
}
2023-10-06 12:52:51 +02:00
meshBytes := mesh.Save()
2023-09-29 16:00:20 +02:00
reply := rpc.GetMeshReply{
2023-10-06 12:52:51 +02:00
Mesh: meshBytes,
2023-09-20 00:50:44 +02:00
}
return &reply, nil
}