debian-mirror-gitlab/lib/gitlab/database/postgresql_adapter/force_disconnectable_mixin.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
702 B
Ruby
Raw Normal View History

2020-04-08 14:13:33 +05:30
# frozen_string_literal: true
module Gitlab
module Database
module PostgresqlAdapter
module ForceDisconnectableMixin
extend ActiveSupport::Concern
prepended do
set_callback :checkin, :after, :force_disconnect_if_old!
end
def force_disconnect_if_old!
if force_disconnect_timer.expired?
disconnect!
reset_force_disconnect_timer!
end
end
def reset_force_disconnect_timer!
force_disconnect_timer.reset!
end
def force_disconnect_timer
2021-09-30 23:02:18 +05:30
@force_disconnect_timer ||= ::Gitlab::Database::ConnectionTimer.starting_now
2020-04-08 14:13:33 +05:30
end
end
end
end
end