class Aws::Plugins::EndpointDiscovery::Handler
def _discover_endpoint(ctx, required)
def _discover_endpoint(ctx, required) cache = ctx.config.endpoint_cache key = cache.extract_key(ctx) if required unless ctx.config.endpoint_discovery raise ArgumentError, "Operation #{ctx.operation.name} requires "\ 'endpoint_discovery to be enabled.' end # required for the operation unless cache.key?(key) cache.update(key, ctx) end endpoint = cache[key] # hard fail if endpoint is not discovered raise Aws::Errors::EndpointDiscoveryError.new unless endpoint endpoint elsif ctx.config.endpoint_discovery # not required for the operation # but enabled if cache.key?(key) cache[key] elsif ctx.config.active_endpoint_cache # enabled active cache pull interval = ctx.config.endpoint_cache_poll_interval if key.include?('_') # identifier related, kill the previous polling thread by key # because endpoint req params might be changed cache.delete_polling_thread(key) end # start a thread for polling endpoints when non-exist unless cache.threads_key?(key) thread = Thread.new do while !cache.key?(key) do cache.update(key, ctx) sleep(interval) end end cache.update_polling_pool(key, thread) end cache[key] else # disabled active cache pull # attempt, buit fail soft cache.update(key, ctx) cache[key] end end end