Fix OpenStack Swift Keystone token rate limiting (#38145)
This commit is contained in:
parent
94aa5d7c9e
commit
4552cda15a
17
config/initializers/fog_connection_cache.rb
Normal file
17
config/initializers/fog_connection_cache.rb
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
if ENV['SWIFT_ENABLED'] == 'true'
|
||||||
|
module PaperclipFogConnectionCache
|
||||||
|
def connection
|
||||||
|
@connection ||= begin
|
||||||
|
key = fog_credentials.hash
|
||||||
|
Thread.current[:paperclip_fog_connections] ||= {}
|
||||||
|
Thread.current[:paperclip_fog_connections][key] ||= ::Fog::Storage.new(fog_credentials)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Rails.application.config.after_initialize do
|
||||||
|
Paperclip::Storage::Fog.prepend(PaperclipFogConnectionCache)
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
x
Reference in New Issue
Block a user