On Thu, Oct 8, 2020 at 1:38 AM 'Rick Selby' via sequel-talk <
[email protected]> wrote:
> Is it possible to refresh the connection settings when reconnecting to a
> database?
>
> We are connecting to an AWS RDS instance using IAM auth - essentially, we
> generate a token to use as a password. This token expires after 15 minutes.
> If the database connection is lost, Sequel will try to reconnect using the
> original token, which may have expired. We need to be able to generate a
> new token when the reconnect happens.
>
One approach is proactively setting the token at an interval slightly less
than 15 minutes:
Thread.new do
loop do
DB.opts[:password] = get_current_iam_password
sleep 890
end
end
A more on-demand setting would be something like (this would be called for
every connection):
def DB.server_opts(_)
opts = super
opts[:password] = get_current_iam_password
opts
end
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/CADGZSSdXSGbKPji_PBBqD_MDOx0bBZCobg3UHdYg1QiURfqjyQ%40mail.gmail.com.