AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Class: Aws::SessionStore::DynamoDB::RackMiddleware

Inherits:
Rack::Session::Abstract::ID
  • Object
show all
Defined in:
lib/aws/session_store/dynamo_db/rack_middleware.rb

Overview

This class is an ID based Session Store Rack Middleware that uses a DynamoDB backend for session storage.

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ RackMiddleware

Initializes SessionStore middleware.

Parameters:

  • app

    Rack application.

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :table_name (String) — default: "Sessions"

    Name of the session table.

  • :table_key (String) — default: "id"

    The hash key of the sesison table.

  • :consistent_read (Boolean) — default: true

    If true, a strongly consistent read is used. If false, an eventually consistent read is used.

  • :read_capacity (Integer) — default: 10

    The maximum number of strongly consistent reads consumed per second before DynamoDB raises a ThrottlingException. See AWS DynamoDB documentation for table read_capacity for more information on this setting.

  • :write_capacity (Integer) — default: 5

    The 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.

  • :dynamo_db_client (DynamoDB Client) — default: Aws::DynamoDB::Client

    DynamoDB client used to perform database operations inside of middleware application.

  • :raise_errors (Boolean) — default: false

    If true, all errors are raised up the stack when default ErrorHandler. If false, Only specified errors are raised up the stack when default ErrorHandler is used.

  • :error_handler (Error Handler) — default: DefaultErrorHandler

    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.

  • :max_age (Integer) — default: nil

    Maximum number of seconds earlier from the current time that a session was created.

  • :max_stale (Integer) — default: nil

    Maximum number of seconds before current time that session was last accessed.

  • :secret_key (String) — default: nil

    Secret key for HMAC encription.

  • :enable_locking (Integer) — default: false

    If true, a pessimistic locking strategy will be implemented for all session accesses. If false, no locking strategy will be implemented for all session accesses.

  • :lock_expiry_time (Integer) — default: 500

    Time in milliseconds after which lock expires on session.

  • :lock_retry_delay (Integer) — default: 500

    Time in milleseconds to wait before retrying to obtain lock once an attempt to obtain lock has been made and has failed.

  • :lock_max_wait_time (Integer) — default: 500

    Maximum time in seconds to wait to acquire lock before giving up.

  • :secret_key (String) — default: SecureRandom.hex(64)

    Secret key for HMAC encription.

Raises:

  • (Aws::DynamoDB::Errors::ResourceNotFoundException)

    If valid table name is not provided.

  • (Aws::SessionStore::DynamoDB::MissingSecretKey)

    If secret key is not provided.



31
32
33
34
35
# File 'lib/aws/session_store/dynamo_db/rack_middleware.rb', line 31

def initialize(app, options = {})
  super
  @config = Configuration.new(options)
  set_locking_strategy
end