diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-02 15:09:46 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-02 15:09:46 +0300 |
commit | 21e08b6197f192c983f8527f4bba1f2aaec8abf2 (patch) | |
tree | bb9183546ba5a3a1d59ed370675d54ac2c90b632 /app/services/pages | |
parent | 43ae0b9e403cf774060267ee6d1a3dd502638068 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/pages')
-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..c39796dff91 --- /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) + + super + end + + def lease_key + "pages_legacy_storage:#{project.id}" + end + + def lease_timeout + LEASE_TIMEOUT + end + end +end |