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 transactions by pulling configuration options from Runtime, a YAML file, the ENV and default settings.
Environment Variables
The Configuration object can load default values from your environment. An example of setting and environment variable is below:
export DYNAMO_DB_SESSION_TABLE_NAME='Sessions'
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, regadless of class, to be raised up the stack and essentially throw a 500.
If you decide to use your own Error Handler. You may pass it in for the value of the key :error_handler as a cofniguration object. You must implement the BaseErrorHandler class.
Locking Strategy
By default, locking is not implemented for the session store. You must trigger the locking strategy through the configuration of the session store. Pessimistic locking, in this case, means 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 accessors with lock in their name for how to configure the pessimistic locking strategy to your needs.
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.
Constant Summary collapse
- DEFAULTS =
Default configuration options
{ :table_name => "sessions", :table_key => "session_id", :consistent_read => true, :read_capacity => 10, :write_capacity => 5, :raise_errors => false, # :max_age => 7*3600*24, # :max_stale => 3600*5, :enable_locking => false, :lock_expiry_time => 500, :lock_retry_delay => 500, :lock_max_wait_time => 1, :secret_key => nil, :api_version => '2012-08-10' }
Instance Attribute Summary collapse
-
#consistent_read ⇒ true, false
readonly
See AWS DynamoDB documentation for table consistent_read for more information on this setting.
-
#dynamo_db_client ⇒ DynamoDB Client
readonly
DynamoDB client.
- #enable_locking ⇒ true, false readonly
-
#error_handler ⇒ Error Handler
readonly
An error handling object that handles all exceptions thrown during execution of the AWS DynamoDB Session Store Rack Middleware.
-
#lock_expiry_time ⇒ Integer
readonly
Time in milleseconds after which lock will expire.
-
#lock_max_wait_time ⇒ Integer
readonly
Maximum time in seconds to wait to acquire lock before giving up.
-
#lock_retry_delay ⇒ Integer
readonly
Time in milleseconds to wait before retrying to obtain lock once an attempt to obtain lock has been made and has failed.
-
#max_age ⇒ Integer
readonly
Maximum number of seconds earlier from the current time that a session was created.
-
#max_stale ⇒ Integer
readonly
Maximum number of seconds before the current time that the session was last accessed.
- #raise_errors ⇒ true, false readonly
-
#read_capacity ⇒ Integer
readonly
Maximum number of reads consumed per second before DynamoDB returns a ThrottlingException.
-
#secret_key ⇒ String
readonly
The secret key for HMAC encryption.
-
#table_key ⇒ String
readonly
Session table hash key name.
-
#table_name ⇒ String
readonly
Session table name.
-
#write_capacity ⇒ Integer
readonly
Maximum number of writes consumed per second before DynamoDB returns a ThrottlingException.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Configuration
constructor
Provides configuration object that allows access to options defined during Runtime, in a YAML file, in the ENV 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 a YAML file, in the ENV and by default.
184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 184 def initialize( = {}) @options = .merge( .merge( ().merge( symbolize_keys() ) ) ) @options = client_error.merge(@options) set_attributes(@options) end |
Instance Attribute Details
#consistent_read ⇒ true, false (readonly)
See AWS DynamoDB documentation for table consistent_read for more information on this setting.
83 84 85 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 83 def consistent_read @consistent_read end |
#dynamo_db_client ⇒ DynamoDB Client (readonly)
Returns DynamoDB client.
102 103 104 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 102 def dynamo_db_client @dynamo_db_client end |
#enable_locking ⇒ true, false (readonly)
124 125 126 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 124 def enable_locking @enable_locking end |
#error_handler ⇒ Error Handler (readonly)
Returns An error handling object that handles all exceptions thrown during execution of the AWS DynamoDB Session Store Rack Middleware. For more information see the Handling Errors Section.
107 108 109 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 107 def error_handler @error_handler end |
#lock_expiry_time ⇒ Integer (readonly)
Returns Time in milleseconds after which lock will expire.
127 128 129 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 127 def lock_expiry_time @lock_expiry_time end |
#lock_max_wait_time ⇒ Integer (readonly)
Returns Maximum time in seconds to wait to acquire lock before giving up.
135 136 137 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 135 def lock_max_wait_time @lock_max_wait_time end |
#lock_retry_delay ⇒ Integer (readonly)
Returns Time in milleseconds to wait before retrying to obtain lock once an attempt to obtain lock has been made and has failed.
131 132 133 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 131 def lock_retry_delay @lock_retry_delay end |
#max_age ⇒ Integer (readonly)
Returns Maximum number of seconds earlier from the current time that a session was created.
111 112 113 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 111 def max_age @max_age end |
#max_stale ⇒ Integer (readonly)
Returns Maximum number of seconds before the current time that the session was last accessed.
115 116 117 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 115 def max_stale @max_stale end |
#raise_errors ⇒ true, false (readonly)
99 100 101 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 99 def raise_errors @raise_errors end |
#read_capacity ⇒ Integer (readonly)
Returns Maximum number of reads consumed per second before DynamoDB returns a ThrottlingException. See AWS DynamoDB documentation for table read_capacity for more information on this setting.
88 89 90 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 88 def read_capacity @read_capacity end |
#secret_key ⇒ String (readonly)
Returns The secret key for HMAC encryption.
118 119 120 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 118 def secret_key @secret_key end |
#table_key ⇒ String (readonly)
Returns Session table hash key name.
77 78 79 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 77 def table_key @table_key end |
#table_name ⇒ String (readonly)
Returns Session table name.
74 75 76 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 74 def table_name @table_name end |
#write_capacity ⇒ Integer (readonly)
Returns Maximum number of writes consumed per second before DynamoDB returns a ThrottlingException. See AWS DynamoDB documentation for table write_capacity for more information on this setting.
93 94 95 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 93 def write_capacity @write_capacity end |
Instance Method Details
#to_hash ⇒ Hash
Returns The merged configuration hash.
197 198 199 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 197 def to_hash @options.dup end |