put_records_with_retry

in lib/fluent/plugin/out_kinesis.rb [270:303]


    def put_records_with_retry(records,retry_count=0)
      response = @client.put_records(
        records: records,
        stream_name: @stream_name
      )

      if response[:failed_record_count] && response[:failed_record_count] > 0
        failed_records = []
        response[:records].each_with_index{|record,index|
          if record[:error_code]
            failed_records.push({body: records[index], error_code: record[:error_code]})
          end
        }

        if(retry_count < @retries_on_putrecords)
          sleep(calculate_sleep_duration(retry_count))
          retry_count += 1
          log.warn sprintf('Retrying to put records. Retry count: %d', retry_count)
          put_records_with_retry(
            failed_records.map{|record| record[:body]},
            retry_count
          )
        else
          failed_records.each{|record|
            log.error sprintf(
              'Could not put record, Error: %s, Record: %s',
              record[:error_code],
              @dump_class.dump(record[:body])
            )
          }
        end
      end
    end