diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /app/services/pages/legacy_storage_lease.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'app/services/pages/legacy_storage_lease.rb')
-rw-r--r-- | app/services/pages/legacy_storage_lease.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/app/services/pages/legacy_storage_lease.rb b/app/services/pages/legacy_storage_lease.rb new file mode 100644 index 00000000000..3f42fc8c63b --- /dev/null +++ b/app/services/pages/legacy_storage_lease.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Pages + module LegacyStorageLease + extend ActiveSupport::Concern + + include ::ExclusiveLeaseGuard + + LEASE_TIMEOUT = 1.hour + + # override method from exclusive lease guard to guard it by feature flag + # TODO: just remove this method after testing this in production + # https://gitlab.com/gitlab-org/gitlab/-/issues/282464 + def try_obtain_lease + return yield unless Feature.enabled?(:pages_use_legacy_storage_lease, project, default_enabled: true) + + super + end + + def lease_key + "pages_legacy_storage:#{project.id}" + end + + def lease_timeout + LEASE_TIMEOUT + end + end +end |