| Module | RightAws::RightAwsBaseInterface |
| In: |
lib/awsbase/right_awsbase.rb
|
| DEFAULT_SIGNATURE_VERSION | = | '2' |
| 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) |
# File lib/awsbase/right_awsbase.rb, line 180
180: def self.caching=(caching)
181: @@caching = caching
182: end
Check if the aws function response hits the cache or not. If the cache hits:
If the cache miss or the caching is off then returns false.
# 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
# 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
# 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.
# File lib/awsbase/right_awsbase.rb, line 293
293: def multi_thread
294: @params[:multi_thread]
295: end
# 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