@@ -4,7 +4,7 @@ import CloudWatch from '../aws/CloudWatch';
4
4
import type {
5
5
TableConsumedCapacityDescription ,
6
6
StatisticSettings ,
7
- ConsumedCapacityDesc
7
+ ConsumedCapacityDesc ,
8
8
} from '../flow/FlowTypes' ;
9
9
import type {
10
10
TableDescription ,
@@ -54,8 +54,8 @@ export default class CapacityCalculatorBase {
54
54
let gsiWrites = ( params . GlobalSecondaryIndexes || [ ] )
55
55
. map ( gsi => this . getConsumedCapacityAsync ( false , params . TableName , gsi . IndexName ) ) ;
56
56
57
- let tableTRead = this . getThrottledEventsAsync ( true , params . TableName , null )
58
- let tableTWrites = this . getThrottledEventsAsync ( false , params . TableName , null )
57
+ let tableTRead = this . getThrottledEventsAsync ( true , params . TableName , null ) ;
58
+ let tableTWrites = this . getThrottledEventsAsync ( false , params . TableName , null ) ;
59
59
60
60
let gsiTReads = ( params . GlobalSecondaryIndexes || [ ] )
61
61
. map ( gsi => this . getThrottledEventsAsync ( true , params . TableName , gsi . IndexName ) ) ;
@@ -79,17 +79,18 @@ export default class CapacityCalculatorBase {
79
79
let gsis = gsiConsumedReads . map ( ( read , i ) => {
80
80
let write = gsiConsumedWrites [ i ] ;
81
81
let throttledWrite = gsiThrottledWrites [ i ] ;
82
- let throttledRead = gsiThrottledReads [ i ]
82
+ let throttledRead = gsiThrottledReads [ i ] ;
83
+ let gsiIndexName = read . globalSecondaryIndexName ;
84
+ invariant ( gsiIndexName != null , '\'gsiIndexName\' was null' ) ;
83
85
return {
84
- // $FlowIgnore: The indexName is not null in this case
85
- IndexName : read . globalSecondaryIndexName ,
86
+ IndexName : gsiIndexName ,
86
87
ConsumedThroughput : {
87
88
ReadCapacityUnits : read . value ,
88
89
WriteCapacityUnits : write . value
89
90
} ,
90
91
ThrottledEvents : {
91
92
ThrottledReadEvents : throttledRead ,
92
- ThrottledWriteEvents : throttledRead
93
+ ThrottledWriteEvents : throttledWrite
93
94
}
94
95
} ;
95
96
} ) ;
@@ -189,19 +190,19 @@ export default class CapacityCalculatorBase {
189
190
Unit : 'Count'
190
191
} ;
191
192
192
- let statistics = await this . cw . getMetricStatisticsAsync ( params ) ;
193
- let value = this . getProjectedValue ( settings , statistics ) ;
194
-
195
- return value ;
196
- } catch ( ex ) {
197
- warning ( JSON . stringify ( {
198
- class : 'CapacityCalculator' ,
199
- function : 'getThrottledEventsAsync' ,
200
- isRead, tableName, globalSecondaryIndexName,
201
- } , null , json . padding ) ) ;
202
- throw ex ;
193
+ let statistics = await this . cw . getMetricStatisticsAsync ( params ) ;
194
+ let value = this . getProjectedValue ( settings , statistics ) ;
195
+
196
+ return value ;
197
+ } catch ( ex ) {
198
+ warning ( JSON . stringify ( {
199
+ class : 'CapacityCalculator' ,
200
+ function : 'getThrottledEventsAsync' ,
201
+ isRead, tableName, globalSecondaryIndexName,
202
+ } , null , json . padding ) ) ;
203
+ throw ex ;
204
+ }
203
205
}
204
- }
205
206
206
207
getDimensions ( tableName : string , globalSecondaryIndexName : ?string ) : Dimension [ ] {
207
208
if ( globalSecondaryIndexName ) {
0 commit comments