diff --git a/cmd/main.go b/cmd/main.go index c84a9f61..1c002297 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -13,7 +13,7 @@ import ( "strings" "time" - "github.com/opiproject/gospdk/spdk" + "github.com/spdk/spdk/go/rpc/client" "github.com/opiproject/opi-spdk-bridge/pkg/backend" "github.com/opiproject/opi-spdk-bridge/pkg/frontend" @@ -137,7 +137,14 @@ func runGrpcServer(grpcPort int, useKvm bool, store gokv.Store, spdkAddress, qmp ) s := grpc.NewServer(serverOptions...) - jsonRPC := spdk.NewClient(spdkAddress) + //create client + jsonRPC, err := client.CreateClientWithJsonCodec(client.TCP, spdkAddress) + if err != nil { + log.Fatalf("error on client creation, err: %s", err.Error()) + } + defer rpcClient.Close() + + // create servers backendServer := backend.NewServer(jsonRPC, store) middleendServer := middleend.NewServer(jsonRPC, store) diff --git a/go.mod b/go.mod index 11297018..f3863c64 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,8 @@ module github.com/opiproject/opi-spdk-bridge -go 1.19 +go 1.21 + +toolchain go1.21.3 require ( github.com/digitalocean/go-qemu v0.0.0-20230711162256-2e3d0186973e @@ -173,6 +175,7 @@ require ( github.com/sivchari/tenv v1.7.1 // indirect github.com/sonatard/noctx v0.0.2 // indirect github.com/sourcegraph/go-diff v0.7.0 // indirect + github.com/spdk/spdk/go/rpc v0.0.0-20231024143024-470e851852bb // indirect github.com/spf13/afero v1.9.3 // indirect github.com/spf13/cast v1.5.0 // indirect github.com/spf13/cobra v1.7.0 // indirect diff --git a/go.sum b/go.sum index cf8b8942..a90d612b 100644 --- a/go.sum +++ b/go.sum @@ -551,6 +551,8 @@ github.com/sonatard/noctx v0.0.2 h1:L7Dz4De2zDQhW8S0t+KUjY0MAQJd6SgVwhzNIc4ok00= github.com/sonatard/noctx v0.0.2/go.mod h1:kzFz+CzWSjQ2OzIm46uJZoXuBpa2+0y3T36U18dWqIo= github.com/sourcegraph/go-diff v0.7.0 h1:9uLlrd5T46OXs5qpp8L/MTltk0zikUGi0sNNyCpA8G0= github.com/sourcegraph/go-diff v0.7.0/go.mod h1:iBszgVvyxdc8SFZ7gm69go2KDdt3ag071iBaWPF6cjs= +github.com/spdk/spdk/go/rpc v0.0.0-20231024143024-470e851852bb h1:LhIOrS8GltzJubkEFkPwjVOgZb9ldUih91vZ2BuGPTo= +github.com/spdk/spdk/go/rpc v0.0.0-20231024143024-470e851852bb/go.mod h1:rpOwUxkcLJ5j1SB80YgfM6277k9RDRxvBMQomeho0EE= github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk= github.com/spf13/afero v1.9.3/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y= github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= diff --git a/pkg/backend/backend.go b/pkg/backend/backend.go index 723e7d87..6ad5e56b 100644 --- a/pkg/backend/backend.go +++ b/pkg/backend/backend.go @@ -9,8 +9,8 @@ import ( "log" "github.com/philippgille/gokv" + "github.com/spdk/spdk/go/rpc/client" - "github.com/opiproject/gospdk/spdk" pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" "github.com/opiproject/opi-spdk-bridge/pkg/utils" ) @@ -33,7 +33,7 @@ type Server struct { pb.UnimplementedNullVolumeServiceServer pb.UnimplementedAioVolumeServiceServer - rpc spdk.JSONRPC + rpc client.Client store gokv.Store Volumes VolumeParameters Pagination map[string]int @@ -42,7 +42,7 @@ type Server struct { // NewServer creates initialized instance of BackEnd server communicating // with provided jsonRPC -func NewServer(jsonRPC spdk.JSONRPC, store gokv.Store) *Server { +func NewServer(jsonRPC client.Client, store gokv.Store) *Server { if jsonRPC == nil { log.Panic("nil for JSONRPC is not allowed") } diff --git a/pkg/frontend/frontend.go b/pkg/frontend/frontend.go index 421964c8..45ff8d8b 100644 --- a/pkg/frontend/frontend.go +++ b/pkg/frontend/frontend.go @@ -9,6 +9,7 @@ import ( "log" "github.com/philippgille/gokv" + "github.com/spdk/spdk/go/rpc/client" "github.com/opiproject/gospdk/spdk" pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" @@ -37,7 +38,7 @@ type Server struct { pb.UnimplementedFrontendVirtioBlkServiceServer pb.UnimplementedFrontendVirtioScsiServiceServer - rpc spdk.JSONRPC + rpc client.Client store gokv.Store Nvme NvmeParameters Virt VirtioParameters @@ -48,7 +49,7 @@ type Server struct { // NewServer creates initialized instance of FrontEnd server communicating // with provided jsonRPC -func NewServer(jsonRPC spdk.JSONRPC, store gokv.Store) *Server { +func NewServer(jsonRPC client.Client, store gokv.Store) *Server { if jsonRPC == nil { log.Panic("nil for JSONRPC is not allowed") } diff --git a/pkg/middleend/middleend.go b/pkg/middleend/middleend.go index 0434ae73..add0dc41 100644 --- a/pkg/middleend/middleend.go +++ b/pkg/middleend/middleend.go @@ -9,8 +9,8 @@ import ( "log" "github.com/philippgille/gokv" + "github.com/spdk/spdk/go/rpc/client" - "github.com/opiproject/gospdk/spdk" pb "github.com/opiproject/opi-api/storage/v1alpha1/gen/go" ) @@ -25,7 +25,7 @@ type Server struct { pb.UnimplementedMiddleendEncryptionServiceServer pb.UnimplementedMiddleendQosVolumeServiceServer - rpc spdk.JSONRPC + rpc client.Client store gokv.Store volumes VolumeParameters Pagination map[string]int @@ -33,7 +33,7 @@ type Server struct { // NewServer creates initialized instance of MiddleEnd server communicating // with provided jsonRPC -func NewServer(jsonRPC spdk.JSONRPC, store gokv.Store) *Server { +func NewServer(jsonRPC client.Client, store gokv.Store) *Server { if jsonRPC == nil { log.Panic("nil for JSONRPC is not allowed") }