Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stroeer/ddb-scanner
Package for scanning DynamoDb tables in parallel.
https://github.com/stroeer/ddb-scanner
dynamodb go golang scan
Last synced: about 1 month ago
JSON representation
Package for scanning DynamoDb tables in parallel.
- Host: GitHub
- URL: https://github.com/stroeer/ddb-scanner
- Owner: stroeer
- License: mit
- Created: 2022-03-29T09:11:51.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-17T07:09:53.000Z (about 1 year ago)
- Last Synced: 2024-06-20T12:41:23.282Z (7 months ago)
- Topics: dynamodb, go, golang, scan
- Language: Go
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ddb-scanner
Package for scanning DynamoDb tables in parallel. This is an updated version of https://github.com/clearbit/go-ddb
## install
```shell
go get github.com/stroeer/ddb-scanner
```## use
```go
const (
region = "eu-west-1"
)type item struct {
Pk string
}func main() {
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))if err != nil {
log.Fatal(err)
}sc := scanner.New(scanner.Config{
Svc: dynamodb.NewFromConfig(cfg),
ProjectionExpression: aws.String("pk"),
Region: aws.String(region),
TableName: aws.String("test"),
TotalSegments: aws.Int32(20),
})start := time.Now()
sc.Start(scanner.HandlerFunc(func(ddbItems []map[string]types.AttributeValue) {
var items []item
err := attributevalue.UnmarshalListOfMaps(ddbItems, &items)
if err != nil {
log.Fatalf("failed to unmarshal ddbItems, %v", err)
}
for _, i := range items {
log.Printf("pk: %s\n", i.Pk)
}
}))
log.Printf("table scan finished - count: %d, segments: %d, duration: %s\n", sc.CompletedItems.Value(), sc.CompletedSegments.Value(), time.Since(start))
}```