Skip to content

Commit

Permalink
Refactor client-server interaction facilities
Browse files Browse the repository at this point in the history
  • Loading branch information
reshke committed Aug 24, 2024
1 parent ce6d6aa commit 8f56a9b
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 143 deletions.
5 changes: 2 additions & 3 deletions cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ import (
"net"
"os"

"github.com/yezzey-gp/yproxy/pkg/storage"

"github.com/spf13/cobra"
"github.com/yezzey-gp/yproxy/config"
"github.com/yezzey-gp/yproxy/pkg/client"
"github.com/yezzey-gp/yproxy/pkg/message"
"github.com/yezzey-gp/yproxy/pkg/object"
"github.com/yezzey-gp/yproxy/pkg/proc"
"github.com/yezzey-gp/yproxy/pkg/ylogger"
)
Expand Down Expand Up @@ -167,7 +166,7 @@ func listFunc(con net.Conn, instanceCnf *config.Instance, args []string) error {
r := proc.NewProtoReader(ycl)

done := false
res := make([]*storage.ObjectInfo, 0)
res := make([]*object.ObjectInfo, 0)
for {
if done {
break
Expand Down
10 changes: 5 additions & 5 deletions pkg/message/object_meta_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import (
"bytes"
"encoding/binary"

"github.com/yezzey-gp/yproxy/pkg/storage"
"github.com/yezzey-gp/yproxy/pkg/object"
)

type ObjectInfoMessage struct {
Content []*storage.ObjectInfo
Content []*object.ObjectInfo
}

var _ ProtoMessage = &ObjectInfoMessage{}

func NewObjectMetaMessage(content []*storage.ObjectInfo) *ObjectInfoMessage {
func NewObjectMetaMessage(content []*object.ObjectInfo) *ObjectInfoMessage {
return &ObjectInfoMessage{
Content: content,
}
Expand Down Expand Up @@ -44,12 +44,12 @@ func (c *ObjectInfoMessage) Encode() []byte {

func (c *ObjectInfoMessage) Decode(body []byte) {
body = body[4:]
c.Content = make([]*storage.ObjectInfo, 0)
c.Content = make([]*object.ObjectInfo, 0)
for len(body) > 0 {
name, index := c.GetString(body)
size := int64(binary.BigEndian.Uint64(body[index : index+8]))

c.Content = append(c.Content, &storage.ObjectInfo{
c.Content = append(c.Content, &object.ObjectInfo{
Path: name,
Size: size,
})
Expand Down
9 changes: 7 additions & 2 deletions pkg/mock/backups.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions pkg/mock/database.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions pkg/mock/proc/yrreader.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 30 additions & 24 deletions pkg/mock/storage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions pkg/object/objectInfo.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package object

type ObjectInfo struct {
Path string
Size int64
}
4 changes: 2 additions & 2 deletions pkg/proc/delete_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"github.com/stretchr/testify/assert"
"github.com/yezzey-gp/yproxy/pkg/message"
mock "github.com/yezzey-gp/yproxy/pkg/mock"
"github.com/yezzey-gp/yproxy/pkg/object"
"github.com/yezzey-gp/yproxy/pkg/proc"
"github.com/yezzey-gp/yproxy/pkg/storage"
)

func TestReworkingName(t *testing.T) {
Expand Down Expand Up @@ -60,7 +60,7 @@ func TestFilesToDeletion(t *testing.T) {
Confirm: false,
}

filesInStorage := []*storage.ObjectInfo{
filesInStorage := []*object.ObjectInfo{
{Path: "1663_16530_not-deleted_18002_"},
{Path: "1663_16530_deleted-after-backup_18002_"},
{Path: "1663_16530_deleted-when-backup-start_18002_"},
Expand Down
Loading

0 comments on commit 8f56a9b

Please sign in to comment.