Class: DynamicLinks::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/dynamic_links/configuration.rb

Overview

Author:

Constant Summary collapse

VALID_DB_INFRA_STRATEGIES =
[:standard, :sharding].freeze
DEFAULT_SHORTENING_STRATEGY =
:md5
DEFAULT_ENABLE_REST_API =
true
DEFAULT_DB_INFRA_STRATEGY =
:standard
DEFAULT_ASYNC_PROCESSING =
false
DEFAULT_REDIS_COUNTER_CONFIG =
RedisConfig.new
DEFAULT_CACHE_STORE =

use any class that extends ActiveSupport::Cache::Store, default is MemoryStore

ActiveSupport::Cache::MemoryStore.new
DEFAULT_ENABLE_FALLBACK_MODE =
false
DEFAULT_FIREBASE_HOST =
nil

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Usage:

DynamicLinks.configure do |config|
  config.shortening_strategy = :md5 # or other strategy name, see StrategyFactory for available strategies
  config.enable_rest_api = true # or false. when false, the API requests will be rejected
  config.db_infra_strategy = :standard # or :sharding. if sharding is used, then xxx
  config.async_processing = false # or true. if true, the shortening process will be done asynchronously using ActiveJob
  config.redis_counter_config = RedisConfig.new # see RedisConfig documentation for more details
  # if you use Redis
  config.cache_store = ActiveSupport::Cache::RedisStore.new('redis://localhost:6379/0/cache')
  # if you use Memcached
  config.cache_store = ActiveSupport::Cache::MemCacheStore.new('localhost:11211')
end


34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dynamic_links/configuration.rb', line 34

def initialize
  @shortening_strategy = DEFAULT_SHORTENING_STRATEGY
  @enable_rest_api = DEFAULT_ENABLE_REST_API
  @db_infra_strategy = DEFAULT_DB_INFRA_STRATEGY
  @async_processing = DEFAULT_ASYNC_PROCESSING
  # config for RedisCounterStrategy
  @redis_counter_config = DEFAULT_REDIS_COUNTER_CONFIG
  @cache_store = DEFAULT_CACHE_STORE
  @enable_fallback_mode = DEFAULT_ENABLE_FALLBACK_MODE
  @firebase_host = DEFAULT_FIREBASE_HOST
end

Instance Attribute Details

#async_processingObject

Returns the value of attribute async_processing.



4
5
6
# File 'lib/dynamic_links/configuration.rb', line 4

def async_processing
  @async_processing
end

#cache_storeObject

Returns the value of attribute cache_store.



4
5
6
# File 'lib/dynamic_links/configuration.rb', line 4

def cache_store
  @cache_store
end

#db_infra_strategyObject

Returns the value of attribute db_infra_strategy.



4
5
6
# File 'lib/dynamic_links/configuration.rb', line 4

def db_infra_strategy
  @db_infra_strategy
end

#enable_fallback_modeObject

Returns the value of attribute enable_fallback_mode.



4
5
6
# File 'lib/dynamic_links/configuration.rb', line 4

def enable_fallback_mode
  @enable_fallback_mode
end

#enable_rest_apiObject

Returns the value of attribute enable_rest_api.



4
5
6
# File 'lib/dynamic_links/configuration.rb', line 4

def enable_rest_api
  @enable_rest_api
end

#firebase_hostObject

Returns the value of attribute firebase_host.



4
5
6
# File 'lib/dynamic_links/configuration.rb', line 4

def firebase_host
  @firebase_host
end

#redis_counter_configObject

Returns the value of attribute redis_counter_config.



4
5
6
# File 'lib/dynamic_links/configuration.rb', line 4

def redis_counter_config
  @redis_counter_config
end

#shortening_strategyObject

Returns the value of attribute shortening_strategy.



4
5
6
# File 'lib/dynamic_links/configuration.rb', line 4

def shortening_strategy
  @shortening_strategy
end