in lib/load.go [96:132]
func GetData(allReq *uint32, successReq *uint32, errorReq *uint32, maxRequest int,
tableName string, awsRegion string, testData []item, threadStartIndex int, threadCount int) (getConsumedCapacity float64) {
fmt.Printf("GET start child execute : time:%v,Counter:%v,MaxRequets:%v\n",
time.Now(), atomic.LoadUint32(allReq), maxRequest)
sess, err := session.NewSession(&aws.Config{Region: aws.String(awsRegion)})
if err != nil {
fmt.Println("GET Got session error:", err.Error())
os.Exit(1)
}
svc := dynamodb.New(sess, aws.NewConfig().WithMaxRetries(0))
var grCount int
fmt.Println("GET This goroutine threadStartIndex:", threadStartIndex, "threadCount:", threadCount)
for i := threadStartIndex; i < threadStartIndex+threadCount; i++ {
item := testData[i]
getData := makeGetTestData(tableName, item.Pk, item.Sk)
result, err := svc.GetItem(getData)
if result != nil {
getConsumedCapacity = getConsumedCapacity + *result.ConsumedCapacity.CapacityUnits
}
if err != nil {
fmt.Printf("GET : getItem error: %v\n", err.Error())
atomic.AddUint32(errorReq, 1)
} else {
atomic.AddUint32(successReq, 1)
}
atomic.AddUint32(allReq, 1)
grCount = grCount + 1
}
fmt.Printf("GET end child execute:time:%v,Counter:%v,consumed capacity:%v\n", time.Now(), grCount, getConsumedCapacity)
return getConsumedCapacity
}