Moved parameters to standalone fle

This commit is contained in:
Riccardo
2022-07-15 16:18:06 +02:00
parent 61f2fff12f
commit 54b2dda79a
8 changed files with 547 additions and 13 deletions

View File

@@ -2,6 +2,7 @@ package db
import (
"context"
"fmt"
"log"
"time"
@@ -78,11 +79,12 @@ func GetTableInfo(c context.Context, api DynamoDBDescribeTableAPI, input *dynamo
return api.DescribeTable(c, input)
}
func AddNewsBatch(basics Table, news []News) (int, error) {
func AddNewsBatch(basics Table, news []News, batchSize int) (int, error) {
fmt.Printf("Writing %v news to db...\n", len(news))
var err error
var item map[string]types.AttributeValue
written := 0
batchSize := 25
start := 0
end := start + batchSize
for start < len(news) {
@@ -109,5 +111,7 @@ func AddNewsBatch(basics Table, news []News) (int, error) {
end += batchSize
}
fmt.Println("Batch insert done.")
return written, err
}