Class: Namespace::AggregationSchedule

Inherits:
ApplicationRecord show all
Includes:
AfterCommitQueue, ExclusiveLeaseGuard
Defined in:
app/models/namespace/aggregation_schedule.rb

Constant Summary collapse

REDIS_SHARED_KEY =
'gitlab:update_namespace_statistics_delay'

Constants inherited from ApplicationRecord

ApplicationRecord::MAX_PLUCK

Constants included from ResetOnUnionError

ResetOnUnionError::MAX_RESET_PERIOD

Instance Method Summary collapse

Methods included from ExclusiveLeaseGuard

#exclusive_lease, #lease_taken_log_level, #lease_taken_message, #log_lease_taken, #release_lease, #renew_lease!, #try_obtain_lease

Methods included from AfterCommitQueue

#run_after_commit, #run_after_commit_or_now

Methods inherited from ApplicationRecord

cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order

Methods included from SensitiveSerializableHash

#serializable_hash

Instance Method Details

#default_lease_timeoutObject



15
16
17
# File 'app/models/namespace/aggregation_schedule.rb', line 15

def default_lease_timeout
  ::Gitlab::CurrentSettings.namespace_aggregation_schedule_lease_duration_in_seconds
end

#schedule_root_storage_statisticsObject



19
20
21
22
23
24
25
26
27
28
29
# File 'app/models/namespace/aggregation_schedule.rb', line 19

def schedule_root_storage_statistics
  run_after_commit_or_now do
    try_obtain_lease do
      Namespaces::RootStatisticsWorker
        .perform_async(namespace_id)

      Namespaces::RootStatisticsWorker
        .perform_in(default_lease_timeout, namespace_id)
    end
  end
end