Moved parameters to standalone fle
This commit is contained in:
8
db/db.go
8
db/db.go
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user