Skip to content

Commit

Permalink
Merge 6dca4ce into 8fd1c7c
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Castell committed Apr 13, 2019
2 parents 8fd1c7c + 6dca4ce commit 5baf4f0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ before_install:
before_script:
- script/travis_consul.sh 1.1.0
- script/travis_etcd.sh 3.3.8
- script/travis_zk.sh 3.4.13
- script/travis_zk.sh 3.4.14
- script/travis_redis.sh 4.0.10
- script/travis_dynamodb_local.sh

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/abronan/valkeyrie

require (
github.com/aws/aws-sdk-go v1.16.23 // indirect
github.com/aws/aws-sdk-go v1.16.23
github.com/coreos/etcd v3.3.11+incompatible
github.com/coreos/go-semver v0.2.0 // indirect
github.com/gogo/protobuf v1.2.0 // indirect
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ github.com/hashicorp/go-rootcerts v1.0.0 h1:Rqb66Oo1X/eSV1x66xbDccZjhJigjg0+e82k
github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU=
github.com/hashicorp/serf v0.8.1 h1:mYs6SMzu72+90OcPa5wr3nfznA4Dw9UyR791ZFNOIf4=
github.com/hashicorp/serf v0.8.1/go.mod h1:h/Ru6tmZazX7WO/GDmwdpS975F019L4t5ng5IgwbNrE=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/mitchellh/go-homedir v1.0.0 h1:vKb8ShqSby24Yrqr/yDYkuFz8d0WUjys40rvnGC8aR0=
Expand Down
30 changes: 24 additions & 6 deletions store/dynamodb/dynamodb.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dynamodb

import (
"context"
"encoding/base64"
"errors"
"fmt"
Expand Down Expand Up @@ -33,8 +34,9 @@ const (
ttlAttribute = "expiration_time"
lockAttribute = "lock"

noExpiration = time.Duration(0)
defaultLockTTL = 20 * time.Second
noExpiration = time.Duration(0)
defaultLockTTL = 20 * time.Second
dynamodbDefaultTimeout = 10 * time.Second
)

var (
Expand Down Expand Up @@ -226,24 +228,40 @@ func (ddb *DynamoDB) List(directory string, options *store.ReadOptions) ([]*stor

filterExp := fmt.Sprintf("begins_with(%s, :namePrefix)", partitionKey)

res, err := ddb.dynamoSvc.Scan(&dynamodb.ScanInput{
si := &dynamodb.ScanInput{
TableName: aws.String(ddb.tableName),
FilterExpression: aws.String(filterExp),
ExpressionAttributeValues: expAttr,
ConsistentRead: aws.Bool(options.Consistent),
})
}

items := []map[string]*dynamodb.AttributeValue{}
ctcx, cancel := context.WithTimeout(context.Background(), dynamodbDefaultTimeout)

err := ddb.dynamoSvc.ScanPagesWithContext(ctcx, si,
func(page *dynamodb.ScanOutput, lastPage bool) bool {
items = append(items, page.Items...)

if lastPage {
cancel()
return true
}

return false
})

if err != nil {
return nil, err
}

if len(res.Items) == 0 {
if len(items) == 0 {
return nil, store.ErrKeyNotFound
}

kvArray := []*store.KVPair{}
val := new(store.KVPair)

for _, item := range res.Items {
for _, item := range items {
val, err = decodeItem(item)
if err != nil {
return nil, err
Expand Down

0 comments on commit 5baf4f0

Please sign in to comment.