lib/sqewer/connection.rb in sqewer-6.5.1 vs lib/sqewer/connection.rb in sqewer-7.0.0
- old
+ new
@@ -209,9 +209,14 @@
end
end
end
def client
+ # It's better using a singleton client to prevent making a lot of HTTP
+ # requests to the AWS metadata endpoint when getting credentials.
+ # Maybe in the future, we can remove @client and use Storm.client only.
+ return Sqewer.client if Sqewer.client
+
@client ||= Aws::SQS::Client.new(
instance_profile_credentials_timeout: 1, # defaults to 1 second
instance_profile_credentials_retries: 5, # defaults to 0 retries
)
end