Module RightAws::RightAwsBaseInterface
In: lib/awsbase/right_awsbase.rb
RuntimeError AwsError AwsNoChange RightAWSParser RightErrorResponseParser RightHttp2xxParser AcfInterface SqsInterface SqsGen2Interface S3Interface Ec2 SdbInterface RightAwsBase ActiveSdbConnect ActiveSdb SqsGen2 S3 S3Generator Sqs RightDummyParser AWSErrorHandler AwsBenchmarkingBlock AwsUtils RightSaxParserCallback lib/sqs/right_sqs_interface.rb lib/sqs/right_sqs_gen2.rb lib/s3/right_s3.rb lib/acf/right_acf_interface.rb lib/sqs/right_sqs_gen2_interface.rb lib/sqs/right_sqs.rb lib/sdb/right_sdb_interface.rb lib/sdb/active_sdb.rb lib/ec2/right_ec2.rb lib/s3/right_s3_interface.rb lib/awsbase/right_awsbase.rb RightAwsBaseInterface VERSION RightAws dot/m_13_0.png

Methods

Constants

DEFAULT_SIGNATURE_VERSION = '2'

Attributes

aws_access_key_id  [R]  Current aws_access_key_id
cache  [R]  Cache
connection  [R]  RightHttpConnection instance
last_errors  [RW]  Last AWS errors list (used by AWSErrorHandler)
last_request  [R]  Last HTTP request object
last_request_id  [RW]  Last AWS request id (used by AWSErrorHandler)
last_response  [R]  Last HTTP response object
logger  [RW]  Logger object
params  [RW]  Initial params hash
signature_version  [R]  Signature version (all services except s3)

Public Class methods

[Source]

     # File lib/awsbase/right_awsbase.rb, line 177
177:     def self.caching
178:       @@caching
179:     end

[Source]

     # File lib/awsbase/right_awsbase.rb, line 180
180:     def self.caching=(caching)
181:       @@caching = caching
182:     end

Public Instance methods

Check if the aws function response hits the cache or not. If the cache hits:

  • raises an AwsNoChange exception if do_raise == +:raise+.
  • returnes parsed response from the cache if it exists or true otherwise.

If the cache miss or the caching is off then returns false.

[Source]

     # File lib/awsbase/right_awsbase.rb, line 254
254:     def cache_hits?(function, response, do_raise=:raise)
255:       result = false
256:       if caching?
257:         function = function.to_sym
258:         # get rid of requestId (this bad boy was added for API 2008-08-08+ and it is uniq for every response)
259:         response = response.sub(%r{<requestId>.+?</requestId>}, '')
260:         response_md5 = MD5.md5(response).to_s
261:         # check for changes
262:         unless @cache[function] && @cache[function][:response_md5] == response_md5
263:           # well, the response is new, reset cache data
264:           update_cache(function, {:response_md5 => response_md5, 
265:                                   :timestamp    => Time.now, 
266:                                   :hits         => 0, 
267:                                   :parsed       => nil})
268:         else
269:           # aha, cache hits, update the data and throw an exception if needed
270:           @cache[function][:hits] += 1
271:           if do_raise == :raise
272:             raise(AwsNoChange, "Cache hit: #{function} response has not changed since "+
273:                                "#{@cache[function][:timestamp].strftime('%Y-%m-%d %H:%M:%S')}, "+
274:                                "hits: #{@cache[function][:hits]}.")
275:           else
276:             result = @cache[function][:parsed] || true
277:           end
278:         end
279:       end
280:       result
281:     end

Returns true if the describe_xxx responses are being cached

[Source]

     # File lib/awsbase/right_awsbase.rb, line 245
245:     def caching?
246:       @params.key?(:cache) ? @params[:cache] : @@caching
247:     end

Returns Amazons request ID for the latest request

[Source]

     # File lib/awsbase/right_awsbase.rb, line 384
384:     def last_request_id
385:       @last_response && @last_response.body.to_s[%r{<requestId>(.+?)</requestId>}] && $1
386:     end

Return true if this instance works in multi_thread mode and false otherwise.

[Source]

     # File lib/awsbase/right_awsbase.rb, line 293
293:     def multi_thread
294:       @params[:multi_thread]
295:     end

[Source]

     # File lib/awsbase/right_awsbase.rb, line 235
235:     def signed_service_params(aws_secret_access_key, service_hash, http_verb=nil, host=nil, service=nil )
236:       case signature_version.to_s
237:       when '0' then AwsUtils::sign_request_v0(aws_secret_access_key, service_hash)
238:       when '1' then AwsUtils::sign_request_v1(aws_secret_access_key, service_hash)
239:       when '2' then AwsUtils::sign_request_v2(aws_secret_access_key, service_hash, http_verb, host, service)
240:       else raise AwsError.new("Unknown signature version (#{signature_version.to_s}) requested")
241:       end
242:     end

[Source]

     # File lib/awsbase/right_awsbase.rb, line 283
283:     def update_cache(function, hash)
284:       (@cache[function.to_sym] ||= {}).merge!(hash) if caching?
285:     end

[Validate]