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 }
Instance Attribute Summary collapse
- #config_file ⇒ String, Pathname readonly
-
#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.
176 177 178 179 180 181 182 183 184 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 176 def initialize( = {}) @options = .merge( .merge( ().merge(symbolize_keys()) ) ) @options = client_error.merge(@options) set_attributes(@options) end |
Instance Attribute Details
#config_file ⇒ String, Pathname (readonly)
118 119 120 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 118 def config_file @config_file end |
#consistent_read ⇒ true, false (readonly)
See AWS DynamoDB documentation for table consistent_read for more information on this setting.
71 72 73 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 71 def consistent_read @consistent_read end |
#dynamo_db_client ⇒ DynamoDB Client (readonly)
Returns DynamoDB client.
123 124 125 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 123 def dynamo_db_client @dynamo_db_client end |
#enable_locking ⇒ true, false (readonly)
101 102 103 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 101 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.
128 129 130 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 128 def error_handler @error_handler end |
#lock_expiry_time ⇒ Integer (readonly)
Returns Time in milleseconds after which lock will expire.
104 105 106 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 104 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.
112 113 114 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 112 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.
108 109 110 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 108 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.
91 92 93 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 91 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.
95 96 97 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 95 def max_stale @max_stale end |
#raise_errors ⇒ true, false (readonly)
87 88 89 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 87 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.
76 77 78 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 76 def read_capacity @read_capacity end |
#secret_key ⇒ String (readonly)
Returns The secret key for HMAC encryption.
115 116 117 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 115 def secret_key @secret_key end |
#table_key ⇒ String (readonly)
Returns Session table hash key name.
65 66 67 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 65 def table_key @table_key end |
#table_name ⇒ String (readonly)
Returns Session table name.
62 63 64 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 62 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.
81 82 83 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 81 def write_capacity @write_capacity end |
Instance Method Details
#to_hash ⇒ Hash
Returns The merged configuration hash.
187 188 189 |
# File 'lib/aws/session_store/dynamo_db/configuration.rb', line 187 def to_hash @options.dup end |