ec2-api-proxy 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ec2-api-proxy/backend.rb +1 -1
- data/lib/ec2-api-proxy/constants.rb +1 -1
- data/lib/ec2-api-proxy/proxy.rb +6 -2
- metadata +1 -1
@@ -1,2 +1,2 @@
|
|
1
1
|
APP_NAME = 'ec2-api-proxy'
|
2
|
-
Version = '0.1.
|
2
|
+
Version = '0.1.1'
|
data/lib/ec2-api-proxy/proxy.rb
CHANGED
@@ -40,15 +40,19 @@ module EC2APIProxy
|
|
40
40
|
EM.defer {
|
41
41
|
begin
|
42
42
|
endpoint, params = parse_proxy_request(data)
|
43
|
+
action = (params['Action'] || []).first
|
44
|
+
allow_cache = !!(/\ADescribe/ =~ action)
|
43
45
|
key = params_to_key(params)
|
44
46
|
|
45
|
-
|
47
|
+
@logger.debug("proxy: #{action} (allow_cache=#{allow_cache})") if @options[:debug]
|
48
|
+
|
49
|
+
if (allow_cache and cache = @memcached.get(key))
|
46
50
|
@logger.debug("proxy: cache hit (length=#{cache.length})") if @options[:debug]
|
47
51
|
send_data(cache)
|
48
52
|
close_connection_after_writing
|
49
53
|
else
|
50
54
|
@logger.debug("proxy: cache miss") if @options[:debug]
|
51
|
-
@backend = EM.connect(endpoint.host, endpoint.port, EC2APIProxy::Backend, self, key)
|
55
|
+
@backend = EM.connect(endpoint.host, endpoint.port, EC2APIProxy::Backend, self, (allow_cache ? key : nil))
|
52
56
|
|
53
57
|
if @backend.error?
|
54
58
|
@logger.error("proxy: backend connection error: #{data.inspect}")
|