Skip to content

Commit

Permalink
More s3 params
Browse files Browse the repository at this point in the history
  • Loading branch information
diPhantxm committed Oct 4, 2024
1 parent b23d038 commit cc2aada
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
16 changes: 13 additions & 3 deletions cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ var (

decrypt bool
/* Put command flags */
encrypt bool
storageClass string
tableSpace string
encrypt bool
storageClass string
tableSpace string
multipart_chunksize int64
multipart_threshold int64

offset uint64

Expand Down Expand Up @@ -115,6 +117,14 @@ func putFunc(con net.Conn, instanceCnf *config.Instance, args []string) error {
Name: message.TableSpaceSetting,
Value: tableSpace,
},
{
Name: message.MultipartChunksize,
Value: fmt.Sprintf("%s", multipart_chunksize),
},
{
Name: message.MultipartThreshold,
Value: fmt.Sprintf("%s", multipart_threshold),
},
}).Encode()
_, err := con.Write(msg)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/message/put_message_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (

const StorageClassSetting = "StorageClass"
const TableSpaceSetting = "TableSpace"
const MultipartChunksize = "MultipartChunksize"
const MultipartThreshold = "MultipartThreshold"

type PutMessageV2 struct {
Encrypt bool
Expand Down
14 changes: 10 additions & 4 deletions pkg/storage/s3storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io"
"path"
"strconv"
"strings"

"github.com/yezzey-gp/aws-sdk-go/aws"
Expand Down Expand Up @@ -69,14 +70,19 @@ func (s *S3StorageInteractor) PutFileToDest(name string, r io.Reader, settings [

objectPath := path.Join(s.cnf.StoragePrefix, name)

storageClass := ResolveStorageSetting(settings, message.StorageClassSetting, "STANDARD")
tableSpace := ResolveStorageSetting(settings, message.TableSpaceSetting, tablespace.DefaultTableSpace)
multipartChunksizeStr := ResolveStorageSetting(settings, message.MultipartChunksize, "")
multipartChunksize, err := strconv.ParseInt(multipartChunksizeStr, 10, 64)
if err != nil {
return err
}

up := s3manager.NewUploaderWithClient(sess, func(uploader *s3manager.Uploader) {
uploader.PartSize = int64(1 << 24)
uploader.PartSize = int64(multipartChunksize)
uploader.Concurrency = 1
})

storageClass := ResolveStorageSetting(settings, message.StorageClassSetting, "STANDARD")
tableSpace := ResolveStorageSetting(settings, message.TableSpaceSetting, tablespace.DefaultTableSpace)

bucket, ok := s.bucketMap[tableSpace]
if !ok {
err := fmt.Errorf("failed to match tablespace %s to s3 bucket.", tableSpace)
Expand Down

0 comments on commit cc2aada

Please sign in to comment.