Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spdk client draft #751

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
6 changes: 3 additions & 3 deletions pkg/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand All @@ -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")
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -37,7 +38,7 @@ type Server struct {
pb.UnimplementedFrontendVirtioBlkServiceServer
pb.UnimplementedFrontendVirtioScsiServiceServer

rpc spdk.JSONRPC
rpc client.Client
store gokv.Store
Nvme NvmeParameters
Virt VirtioParameters
Expand All @@ -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")
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/middleend/middleend.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -25,15 +25,15 @@ type Server struct {
pb.UnimplementedMiddleendEncryptionServiceServer
pb.UnimplementedMiddleendQosVolumeServiceServer

rpc spdk.JSONRPC
rpc client.Client
store gokv.Store
volumes VolumeParameters
Pagination map[string]int
}

// 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")
}
Expand Down
Loading