Skip to content

Commit

Permalink
refactor(spdk): rename SpdkClientAdapter to ClientAdapter
Browse files Browse the repository at this point in the history
type name will be used as spdk.SpdkClientAdapter by other
packages, and that stutters; consider calling this ClientAdapter

Signed-off-by: Artsiom Koltun <[email protected]>
  • Loading branch information
artek-koltun committed Jan 30, 2024
1 parent 41d0d6a commit d39270f
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pkg/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type Server struct {
pb.UnimplementedNullVolumeServiceServer
pb.UnimplementedAioVolumeServiceServer

rpc *spdk.SpdkClientAdapter
rpc *spdk.ClientAdapter
store gokv.Store
Volumes VolumeParameters
Pagination map[string]int
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type Server struct {
pb.UnimplementedFrontendVirtioBlkServiceServer
pb.UnimplementedFrontendVirtioScsiServiceServer

rpc *spdk.SpdkClientAdapter
rpc *spdk.ClientAdapter
store gokv.Store
Nvme NvmeParameters
Virt VirtioParameters
Expand Down
2 changes: 1 addition & 1 deletion pkg/frontend/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type VirtioBlkTransport interface {
}

type nvmeTCPTransport struct {
rpc *spdk.SpdkClientAdapter
rpc *spdk.ClientAdapter
}

// build time check that struct implements interface
Expand Down
2 changes: 1 addition & 1 deletion pkg/kvm/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

type nvmeVfiouserTransport struct {
ctrlrDir string
rpc *spdk.SpdkClientAdapter
rpc *spdk.ClientAdapter
}

// build time check that struct implements interface
Expand Down
2 changes: 1 addition & 1 deletion pkg/middleend/middleend.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type Server struct {
pb.UnimplementedMiddleendEncryptionServiceServer
pb.UnimplementedMiddleendQosVolumeServiceServer

rpc *spdk.SpdkClientAdapter
rpc *spdk.ClientAdapter
store gokv.Store
volumes VolumeParameters
tweakMode string
Expand Down
12 changes: 6 additions & 6 deletions pkg/spdk/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ import (
"github.com/spdk/spdk/go/rpc/client"
)

// SpdkClientAdapter provides an adapter between old gospdk api and new spdk client
// ClientAdapter provides an adapter between old gospdk api and new spdk client
// This is needed due to:
// * awkward response unmarshaling in the new client. A Result in Response is
// provided in the form described in json.Unmarshal
// * New error codes affecting a lot of tests. The adapter converts the new
// format to the old one. It enables gradual transition. The tests will be
// reworked to new errors eliminating transformations in the adapter.
type SpdkClientAdapter struct {
type ClientAdapter struct {
client client.IClient
}

// NewSpdkClientAdapter creates a new instance if SpdkClientAdapter
func NewSpdkClientAdapter(client client.IClient) *SpdkClientAdapter {
return &SpdkClientAdapter{client}
func NewSpdkClientAdapter(client client.IClient) *ClientAdapter {
return &ClientAdapter{client}
}

// Call performs a call to spdk client and unmarshalls the result into requested structure
func (c *SpdkClientAdapter) Call(ctx context.Context, method string, params any, result any) error {
func (c *ClientAdapter) Call(ctx context.Context, method string, params any, result any) error {
ch := make(chan error)

go func() {
Expand All @@ -58,7 +58,7 @@ func (c *SpdkClientAdapter) Call(ctx context.Context, method string, params any,
}
}

func (c *SpdkClientAdapter) convertToLegacyErrorFormat(err error, method string) error {
func (c *ClientAdapter) convertToLegacyErrorFormat(err error, method string) error {
e := errors.Unwrap(err)
spdkErr, _ := e.(*client.Error)

Expand Down

0 comments on commit d39270f

Please sign in to comment.