Class: Aws::SessionStore::DynamoDB::Configuration
- Inherits:
-
Object
- Object
- Aws::SessionStore::DynamoDB::Configuration
- Defined in:
- lib/aws/session_store/dynamo_db/configuration.rb
Overview
This class provides a Configuration object for all DynamoDB session store operations by pulling configuration options from Runtime, the ENV, a YAML file, and default settings, in that order.
Environment Variables
The Configuration object can load default values from your environment. All configuration keys are supported except for :dynamo_db_client
and :error_handler
. The keys take the form of AWS_DYNAMO_DB_SESSION_<KEY_NAME>. Example:
export AWS_DYNAMO_DB_SESSION_TABLE_NAME='Sessions'
export AWS_DYNAMO_DB_SESSION_TABLE_KEY='id'
Locking Strategy
By default, locking is disabled for session store access. To enable locking, set the :enable_locking
option to true. The locking strategy is pessimistic, meaning that only one read can be made on a session at once. While the session is being read by the process with the lock, other processes may try to obtain a lock on the same session but will be blocked. See the initializer for how to configure the pessimistic locking strategy to your needs.
Handling Errors
There are two configurable options for error handling: :raise_errors
and :error_handler
.
If you would like to use the Default Error Handler, you can decide to set :raise_errors
to true or false depending on whether you want all errors, regardless of class, to be raised up the stack and essentially throw a 500.
If you decide to use your own Error Handler, you must implement the BaseErrorHandler
class and pass it into the :error_handler
option.
DynamoDB Specific Options
You may configure the table name and table hash key value of your session table with the :table_name
and :table_key
options. You may also configure performance options for your table with the :consistent_read
, :read_capacity
, :write_capacity
. For more information about these configurations see CreateTable method for Amazon DynamoDB.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Configuration
constructor
Provides configuration object that allows access to options defined during Runtime, in the ENV, in a YAML file, and by default.
-
#to_hash ⇒ Hash
The merged configuration hash.
Constructor Details
#initialize(options = {}) ⇒ Configuration
Provides configuration object that allows access to options defined during Runtime, in the ENV, in a YAML file, and by default.
101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 101 def initialize( = {}) opts = opts = .merge(opts) opts = (opts).merge(opts) MEMBERS.each_pair do |opt_name, default_value| opts[opt_name] = default_value unless opts.key?(opt_name) end opts = opts.merge(dynamo_db_client: default_dynamo_db_client(opts)) opts = opts.merge(error_handler: default_error_handler(opts)) unless opts[:error_handler] set_attributes(opts) end |
Instance Method Details
#to_hash ⇒ Hash
Returns The merged configuration hash.
119 120 121 122 123 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 119 def to_hash MEMBERS.each_with_object({}) do |(key, _), hash| hash[key] = send(key) end end |