Sha256: 54c73dc9309ae86fe8461d3db034fed57cf0cf35e22992ee6bfadb09cf9a7a38

Contents?: true

Size: 1.59 KB

Versions: 35

Compression:

Stored size: 1.59 KB

Contents

var AWS = require('../core');
require('../dynamodb/document_client');

AWS.util.update(AWS.DynamoDB.prototype, {
  /**
   * @api private
   */
  setupRequestListeners: function setupRequestListeners(request) {
    if (request.service.config.dynamoDbCrc32) {
      request.removeListener('extractData', AWS.EventListeners.Json.EXTRACT_DATA);
      request.addListener('extractData', this.checkCrc32);
      request.addListener('extractData', AWS.EventListeners.Json.EXTRACT_DATA);
    }
  },

  /**
   * @api private
   */
  checkCrc32: function checkCrc32(resp) {
    if (!resp.httpResponse.streaming && !resp.request.service.crc32IsValid(resp)) {
      resp.data = null;
      resp.error = AWS.util.error(new Error(), {
        code: 'CRC32CheckFailed',
        message: 'CRC32 integrity check failed',
        retryable: true
      });
      resp.request.haltHandlersOnError();
      throw (resp.error);
    }
  },

  /**
   * @api private
   */
  crc32IsValid: function crc32IsValid(resp) {
    var crc = resp.httpResponse.headers['x-amz-crc32'];
    if (!crc) return true; // no (valid) CRC32 header
    return parseInt(crc, 10) === AWS.util.crypto.crc32(resp.httpResponse.body);
  },

  /**
   * @api private
   */
  defaultRetryCount: 10,

  /**
   * @api private
   */
  retryDelays: function retryDelays(retryCount) {
    var retryDelayOptions = AWS.util.copy(this.config.retryDelayOptions);

    if (typeof retryDelayOptions.base !== 'number') {
        retryDelayOptions.base = 50; // default for dynamodb
    }
    var delay = AWS.util.calculateRetryDelay(retryCount, retryDelayOptions);
    return delay;
  }
});

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
sumomo-0.10.8 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.10.4 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.10.3 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.10.2 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.10.1 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.10.0 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.9.0 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.22 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.21 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.20 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.17 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.16 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.15 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.14 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.13 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.12 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.11 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.10 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.9 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js
sumomo-0.8.8 data/sumomo/api_modules/node_modules/aws-sdk/lib/services/dynamodb.js