@@ -4,7 +4,7 @@ import CloudWatch from '../aws/CloudWatch';
44import type {
55 TableConsumedCapacityDescription ,
66 StatisticSettings ,
7- ConsumedCapacityDesc
7+ ConsumedCapacityDesc ,
88} from '../flow/FlowTypes' ;
99import type {
1010 TableDescription ,
@@ -54,8 +54,8 @@ export default class CapacityCalculatorBase {
5454 let gsiWrites = ( params . GlobalSecondaryIndexes || [ ] )
5555 . map ( gsi => this . getConsumedCapacityAsync ( false , params . TableName , gsi . IndexName ) ) ;
5656
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 ) ;
5959
6060 let gsiTReads = ( params . GlobalSecondaryIndexes || [ ] )
6161 . map ( gsi => this . getThrottledEventsAsync ( true , params . TableName , gsi . IndexName ) ) ;
@@ -79,17 +79,18 @@ export default class CapacityCalculatorBase {
7979 let gsis = gsiConsumedReads . map ( ( read , i ) => {
8080 let write = gsiConsumedWrites [ i ] ;
8181 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' ) ;
8385 return {
84- // $FlowIgnore: The indexName is not null in this case
85- IndexName : read . globalSecondaryIndexName ,
86+ IndexName : gsiIndexName ,
8687 ConsumedThroughput : {
8788 ReadCapacityUnits : read . value ,
8889 WriteCapacityUnits : write . value
8990 } ,
9091 ThrottledEvents : {
9192 ThrottledReadEvents : throttledRead ,
92- ThrottledWriteEvents : throttledRead
93+ ThrottledWriteEvents : throttledWrite
9394 }
9495 } ;
9596 } ) ;
@@ -189,19 +190,19 @@ export default class CapacityCalculatorBase {
189190 Unit : 'Count'
190191 } ;
191192
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+ }
203205 }
204- }
205206
206207 getDimensions ( tableName : string , globalSecondaryIndexName : ?string ) : Dimension [ ] {
207208 if ( globalSecondaryIndexName ) {
0 commit comments