Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
reshke committed Nov 10, 2023
1 parent e23bb91 commit ec29690
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion pkg/proc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ func ProcConn(s storage.StorageReader, c net.Conn) error {

switch tp {
case MessageTypeCat:
name := GetCatName(body)
// omit first byte
name := GetCatName(body[1:])
ylogger.Zero.Debug().Str("object-path", name).Msg("cat object ")
r, err := s.CatFileFromStorage(name)
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions pkg/storage/sessionpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/aws/aws-sdk-go/service/s3"
"github.com/pkg/errors"
"github.com/yezzey-gp/yproxy/config"
"github.com/yezzey-gp/yproxy/pkg/ylogger"
)

type SessionPool interface {
Expand Down Expand Up @@ -35,6 +36,9 @@ func (sp *S3SessionPool) createSession() (*session.Session, error) {
AccessKeyID: sp.cnf.AccessKeyId,
SecretAccessKey: sp.cnf.SecretAccessKey,
}}

ylogger.Zero.Debug().Str("endpoint", sp.cnf.StorageEndpoint).Msg("acquire external storage session")

providers := make([]credentials.Provider, 0)
providers = append(providers, provider)
providers = append(providers, defaults.CredProviders(s.Config, defaults.Handlers())...)
Expand All @@ -45,6 +49,8 @@ func (sp *S3SessionPool) createSession() (*session.Session, error) {

s.Config.WithRegion(sp.cnf.StorageRegion)

s.Config.WithEndpoint(sp.cnf.StorageEndpoint)

s.Config.WithCredentials(newCredentials)
return s, err
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/storage/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ func (s *S3StorageReader) CatFileFromStorage(name string) (io.Reader, error) {
Key: aws.String(objectPath),
}

ylogger.Zero.Debug().Str("key", objectPath).Str("bucket", s.cnf.StorageBucket).Msg("requesting external storage")
ylogger.Zero.Debug().Str("key", objectPath).Str("bucket",
s.cnf.StorageBucket).Msg("requesting external storage")

object, err := sess.GetObject(input)
return object.Body, err
}

0 comments on commit ec29690

Please sign in to comment.