Module: ActiveRecordProxyAdapters::Mixin::Configuration

Included in:
Context, LogSubscriber, ActiveRecordProxyAdapters::Middleware, ActiveRecordProxyAdapters::Middleware, PrimaryReplicaProxy
Defined in:
lib/active_record_proxy_adapters/mixin/configuration.rb

Overview

Provides helpers to access to reduce boilerplate while retrieving configuration properties.

Instance Method Summary collapse

Instance Method Details

#cache_key_for(sql_string) ⇒ String

Helper to retrieve the cache key prefix from the configuration stored in CacheConfiguration#key_prefix. It uses the key builder to generate a cache key for the given SQL string, prepended with the key prefix.

Returns:

  • (String)


67
68
69
# File 'lib/active_record_proxy_adapters/mixin/configuration.rb', line 67

def cache_key_for(sql_string)
  cache_config.key_builder.call(sql_string).prepend(cache_config.key_prefix)
end

#cache_storeActiveSupport::Cache::Store

Helper to retrieve the cache store from the configuration stored in CacheConfiguration#store.

Returns:

  • (ActiveSupport::Cache::Store)


59
60
61
# File 'lib/active_record_proxy_adapters/mixin/configuration.rb', line 59

def cache_store
  cache_config.store
end

#checkout_timeout(database_name) ⇒ ActiveSupport::Duration

Helper to retrieve the checkout timeout from the configuration stored in DatabaseConfiguration#checkout_timeout.

Parameters:

  • database_name (Symbol, String)

    The name of the database to retrieve the checkout timeout for.

Returns:

  • (ActiveSupport::Duration)


31
32
33
# File 'lib/active_record_proxy_adapters/mixin/configuration.rb', line 31

def checkout_timeout(database_name)
  database_config(database_name).checkout_timeout
end

#context_storeClass

Helper to retrieve the context store class from the configuration stored in Configuration#context_store.

Returns:

  • (Class)


38
39
40
# File 'lib/active_record_proxy_adapters/mixin/configuration.rb', line 38

def context_store
  proxy_config.context_store
end

#log_subscriber_prefix(database_name) ⇒ Proc

Helper to retrieve the proxy delay from the configuration stored in DatabaseConfiguration#log_subscriber_prefix.

Parameters:

  • database_name (Symbol, String)

    The name of the database to retrieve the prefix.

Returns:

  • (Proc)


15
16
17
# File 'lib/active_record_proxy_adapters/mixin/configuration.rb', line 15

def log_subscriber_prefix(database_name)
  database_config(database_name).log_subscriber_prefix
end

#loggerLogger

Helper to retrieve the logger from the configuration stored in Configuration#logger.

Returns:

  • (Logger)


45
46
47
# File 'lib/active_record_proxy_adapters/mixin/configuration.rb', line 45

def logger
  proxy_config.logger
end

#proxy_delay(database_name) ⇒ ActiveSupport::Duration

Helper to retrieve the proxy delay from the configuration stored in DatabaseConfiguration#proxy_delay.

Parameters:

  • database_name (Symbol, String)

    The name of the database to retrieve the proxy delay for.

Returns:

  • (ActiveSupport::Duration)


23
24
25
# File 'lib/active_record_proxy_adapters/mixin/configuration.rb', line 23

def proxy_delay(database_name)
  database_config(database_name).proxy_delay
end

#regexp_timeout_strategyProc

Helper to retrieve the timeout strategy from the configuration stored in Configuration#regexp_timeout_strategy.

Returns:

  • (Proc)


52
53
54
# File 'lib/active_record_proxy_adapters/mixin/configuration.rb', line 52

def regexp_timeout_strategy
  proxy_config.regexp_timeout_strategy
end