Skip to content

Commit 61ec144

Browse files
committed
Renamed DynamoDB::SessionStore to SessionStore::DynamoDB
1 parent 87c9f4f commit 61ec144

27 files changed

+109
-79
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Ruby file using the following method:
3737

3838
require 'aws-sessionstore-dynamodb'
3939

40-
AWS::DynamoDB::SessionStore::Table.create_table
40+
AWS::SessionStore::DynamoDB::Table.create_table
4141

4242
Run the session store as a Rack middleware in the following way:
4343

@@ -46,7 +46,7 @@ Run the session store as a Rack middleware in the following way:
4646

4747
options = { :secret_key => 'SECRET_KEY' }
4848

49-
use AWS::DynamoDB::SessionStore::RackMiddleware.new(options)
49+
use AWS::SessionStore::DynamoDB::RackMiddleware.new(options)
5050
run SomeRackApp
5151

5252
Note that `:secret_key` is a mandatory configuration option that must be set.
@@ -69,7 +69,7 @@ scalable storage container with a much larger data size limit for session data.
6969
### Configuration Options
7070

7171
The following options are available to be set in
72-
`AWS::DynamoDB::SessionStore::Configuration`, which is used by the
72+
`AWS::SessionStore::DynamoDB::Configuration`, which is used by the
7373
`RackMiddleware` class. These options can be set in the YAML configuration
7474
file in a Rails application, directly by Ruby code, or environment variables.
7575

@@ -203,7 +203,7 @@ You can create your own Rake task for garbage collection similar to below:
203203
desc 'Perform Garbage Collection'
204204
task :garbage_collect do |t|
205205
options = {:max_age => 3600*24, max_stale => 5*3600 }
206-
AWS::DynamoDB::SessionStore::GarbageCollection.collect_garbage(options)
206+
AWS::SessionStore::DynamoDB::GarbageCollection.collect_garbage(options)
207207
end
208208

209209
The above example will clear sessions older than one day or that have been
@@ -241,5 +241,5 @@ locking strategy according to your needs:
241241

242242
You can pass in your own error handler for raised exceptions or you can allow
243243
the default error handler to them for you. See the API documentation
244-
on the {AWS::DynamoDB::SessionStore::Errors::BaseHandler} class for more
244+
on the {AWS::SessionStore::DynamoDB::Errors::BaseHandler} class for more
245245
details.

aws-sessionstore-dynamodb.gemspec

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
require File.dirname(__FILE__) + '/lib/aws/session_store/dynamo_db/version'
2+
13
Gem::Specification.new do |spec|
24
spec.name = "aws-sessionstore-dynamodb"
3-
spec.version = "0.5.0"
5+
spec.version = AWS::SessionStore::DynamoDB::VERSION
46
spec.authors = ["Ruby Robinson"]
5-
spec.summary = "The Amazon DynamoDB Session Store handles sessions for Ruby web applications using a DynamoDB backend."
7+
spec.summary = "The Amazon DynamoDB Session Store handles sessions " +
8+
"for Ruby web applications using a DynamoDB backend."
69
spec.homepage = "http://github.com/aws/aws-sessionstore-dynamodb-ruby"
710
spec.license = "Apache License 2.0"
811

lib/aws-sessionstore-dynamodb.rb

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,23 @@
1212
# language governing permissions and limitations under the License.
1313

1414

15-
require 'aws/dynamo_db/session_store/configuration'
16-
require 'aws/dynamo_db/session_store/invalid_id_error'
17-
require 'aws/dynamo_db/session_store/missing_secret_key_error'
18-
require 'aws/dynamo_db/session_store/lock_wait_timeout_error'
19-
require 'aws/dynamo_db/session_store/errors/base_handler'
20-
require 'aws/dynamo_db/session_store/errors/default_handler'
21-
require 'aws/dynamo_db/session_store/garbage_collection'
22-
require 'aws/dynamo_db/session_store/locking/base'
23-
require 'aws/dynamo_db/session_store/locking/null'
24-
require 'aws/dynamo_db/session_store/locking/pessimistic'
25-
require 'aws/dynamo_db/session_store/rack_middleware'
26-
require 'aws/dynamo_db/session_store/table'
27-
require 'aws/dynamo_db/session_store/version'
28-
require 'aws/dynamo_db/session_store/railtie' if defined?(Rails)
15+
module AWS
16+
module SessionStore
17+
module DynamoDB; end
18+
end
19+
end
20+
21+
require 'aws/session_store/dynamo_db/configuration'
22+
require 'aws/session_store/dynamo_db/invalid_id_error'
23+
require 'aws/session_store/dynamo_db/missing_secret_key_error'
24+
require 'aws/session_store/dynamo_db/lock_wait_timeout_error'
25+
require 'aws/session_store/dynamo_db/errors/base_handler'
26+
require 'aws/session_store/dynamo_db/errors/default_handler'
27+
require 'aws/session_store/dynamo_db/garbage_collection'
28+
require 'aws/session_store/dynamo_db/locking/base'
29+
require 'aws/session_store/dynamo_db/locking/null'
30+
require 'aws/session_store/dynamo_db/locking/pessimistic'
31+
require 'aws/session_store/dynamo_db/rack_middleware'
32+
require 'aws/session_store/dynamo_db/table'
33+
require 'aws/session_store/dynamo_db/version'
34+
require 'aws/session_store/dynamo_db/railtie' if defined?(Rails)

lib/aws/session_store/dynamo_db/configuration.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
require 'yaml'
1515
require 'aws-sdk'
1616

17-
module AWS::DynamoDB::SessionStore
17+
module AWS::SessionStore::DynamoDB
1818
# This class provides a Configuration object for all DynamoDB transactions
1919
# by pulling configuration options from Runtime, a YAML file, the ENV and
2020
# default settings.
@@ -210,7 +210,7 @@ def gen_dynamo_db_client
210210

211211
# @return [Hash] Default Error Handler
212212
def gen_error_handler
213-
default_handler = AWS::DynamoDB::SessionStore::Errors::DefaultHandler
213+
default_handler = AWS::SessionStore::DynamoDB::Errors::DefaultHandler
214214
error_handler = @options[:error_handler] ||
215215
default_handler.new(@options[:raise_errors])
216216
{:error_handler => error_handler}

lib/aws/session_store/dynamo_db/errors/base_handler.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# language governing permissions and limitations under the License.
1313

1414

15-
module AWS::DynamoDB::SessionStore::Errors
15+
module AWS::SessionStore::DynamoDB::Errors
1616
# BaseErrorHandler provides an interface for error handlers
17-
# that can be passed in to {AWS::DynamoDB::SessionStore::RackMiddleware}.
17+
# that can be passed in to {AWS::SessionStore::DynamoDB::RackMiddleware}.
1818
# Each error handler must implement a handle_error method.
1919
#
2020
# @example Sample ErrorHandler class
@@ -34,7 +34,7 @@ class BaseHandler
3434
# You may reraise the error passed.
3535
#
3636
# @param [AWS::DynamoDB::Errors::Base] error error passed in from
37-
# AWS::DynamoDB::SessionStore::RackMiddleware.
37+
# AWS::SessionStore::DynamoDB::RackMiddleware.
3838
# @param [Rack::Request::Environment,nil] env Rack environment
3939
# @return [false] If exception was handled and will not reraise exception.
4040
# @raise [AWS::DynamoDB::Errors] If error has be reraised.

lib/aws/session_store/dynamo_db/errors/default_handler.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
# language governing permissions and limitations under the License.
1313

1414

15-
module AWS::DynamoDB::SessionStore::Errors
15+
module AWS::SessionStore::DynamoDB::Errors
1616
# This class handles errors raised from DynamoDB.
17-
class DefaultHandler < AWS::DynamoDB::SessionStore::Errors::BaseHandler
17+
class DefaultHandler < AWS::SessionStore::DynamoDB::Errors::BaseHandler
1818
# Array of errors that will always be passed up the Rack stack.
1919
HARD_ERRORS = [
2020
AWS::DynamoDB::Errors::ResourceNotFoundException,
2121
AWS::DynamoDB::Errors::ConditionalCheckFailedException,
22-
AWS::DynamoDB::SessionStore::MissingSecretKeyError,
23-
AWS::DynamoDB::SessionStore::LockWaitTimeoutError
22+
AWS::SessionStore::DynamoDB::MissingSecretKeyError,
23+
AWS::SessionStore::DynamoDB::LockWaitTimeoutError
2424
]
2525

2626
# Determines behavior of DefaultErrorHandler

lib/aws/session_store/dynamo_db/garbage_collection.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
require 'aws-sdk'
1515

16-
module AWS::DynamoDB::SessionStore
16+
module AWS::SessionStore::DynamoDB
1717
# Collects and deletes unwanted sessions based on
1818
# their creation and update dates.
1919
module GarbageCollection
@@ -34,7 +34,7 @@ def collect_garbage(options = {})
3434
# @option (see Configuration#initialize)
3535
# @api private
3636
def load_config(options = {})
37-
AWS::DynamoDB::SessionStore::Configuration.new(options)
37+
AWS::SessionStore::DynamoDB::Configuration.new(options)
3838
end
3939

4040
# Sets scan filter attributes based on attributes specified.

lib/aws/session_store/dynamo_db/invalid_id_error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# language governing permissions and limitations under the License.
1313

1414

15-
module AWS::DynamoDB::SessionStore
15+
module AWS::SessionStore::DynamoDB
1616
class InvalidIDError < RuntimeError
1717
def initialize(msg = "Corrupt Session ID!")
1818
super

lib/aws/session_store/dynamo_db/lock_wait_timeout_error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# language governing permissions and limitations under the License.
1313

1414

15-
module AWS::DynamoDB::SessionStore
15+
module AWS::SessionStore::DynamoDB
1616
class LockWaitTimeoutError < RuntimeError
1717
def initialize(msg = 'Maximum time spent to acquire lock has been exceeded!')
1818
super

lib/aws/session_store/dynamo_db/locking/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# language governing permissions and limitations under the License.
1313

1414

15-
module AWS::DynamoDB::SessionStore::Locking
15+
module AWS::SessionStore::DynamoDB::Locking
1616
# This class provides a framework for implementing
1717
# locking strategies.
1818
class Base

lib/aws/session_store/dynamo_db/locking/null.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
# language governing permissions and limitations under the License.
1313

1414

15-
module AWS::DynamoDB::SessionStore::Locking
15+
module AWS::SessionStore::DynamoDB::Locking
1616
# This class gets and sets sessions
1717
# without a locking strategy.
18-
class Null < AWS::DynamoDB::SessionStore::Locking::Base
18+
class Null < AWS::SessionStore::DynamoDB::Locking::Base
1919
# Retrieve session if it exists from the database by id.
2020
# Unpack the data once retrieved from the database.
2121
def get_session_data(env, sid)

lib/aws/session_store/dynamo_db/locking/pessimistic.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
# language governing permissions and limitations under the License.
1313

1414

15-
module AWS::DynamoDB::SessionStore::Locking
15+
module AWS::SessionStore::DynamoDB::Locking
1616
# This class implements a pessimistic locking strategy for the
1717
# DynamoDB session handler. Sessions obtain an exclusive lock
1818
# for reads that is only released when the session is saved.
19-
class Pessimistic < AWS::DynamoDB::SessionStore::Locking::Base
19+
class Pessimistic < AWS::SessionStore::DynamoDB::Locking::Base
2020
WAIT_ERROR =
2121

2222
# Saves the session.
@@ -58,7 +58,7 @@ def get_session_with_lock(env, sid)
5858
# @raise [Error] When time for attempting to get lock has
5959
# been exceeded.
6060
def exceeded_wait_time?(max_attempt_date)
61-
lock_error = AWS::DynamoDB::SessionStore::LockWaitTimeoutError
61+
lock_error = AWS::SessionStore::DynamoDB::LockWaitTimeoutError
6262
raise lock_error if Time.now.to_f > max_attempt_date
6363
end
6464

lib/aws/session_store/dynamo_db/missing_secret_key_error.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# language governing permissions and limitations under the License.
1313

1414

15-
module AWS::DynamoDB::SessionStore
15+
module AWS::SessionStore::DynamoDB
1616
class MissingSecretKeyError < RuntimeError
1717
def initialize(msg = "No secret key provided!")
1818
super

lib/aws/session_store/dynamo_db/rack_middleware.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
require 'openssl'
1616
require 'aws-sdk'
1717

18-
module AWS::DynamoDB::SessionStore
18+
module AWS::SessionStore::DynamoDB
1919
# This class is an ID based Session Store Rack Middleware
2020
# that uses a DynamoDB backend for session storage.
2121
class RackMiddleware < Rack::Session::Abstract::ID
@@ -26,7 +26,7 @@ class RackMiddleware < Rack::Session::Abstract::ID
2626
# @option (see Configuration#initialize)
2727
# @raise [AWS::DynamoDB::Errors::ResourceNotFoundException] If valid table
2828
# name is not provided.
29-
# @raise [AWS::DynamoDB::SessionStore::MissingSecretKey] If secret key is
29+
# @raise [AWS::SessionStore::DynamoDB::MissingSecretKey] If secret key is
3030
# not provided.
3131
def initialize(app, options = {})
3232
super
@@ -42,9 +42,9 @@ def initialize(app, options = {})
4242
# @return [Locking::Pessimistic] If locking is enabled.
4343
def set_locking_strategy
4444
if @config.enable_locking
45-
@lock = AWS::DynamoDB::SessionStore::Locking::Pessimistic.new(@config)
45+
@lock = AWS::SessionStore::DynamoDB::Locking::Pessimistic.new(@config)
4646
else
47-
@lock = AWS::DynamoDB::SessionStore::Locking::Null.new(@config)
47+
@lock = AWS::SessionStore::DynamoDB::Locking::Null.new(@config)
4848
end
4949
end
5050

@@ -100,7 +100,7 @@ def handle_error(env = nil, &block)
100100
begin
101101
yield
102102
rescue AWS::DynamoDB::Errors::Base,
103-
AWS::DynamoDB::SessionStore::InvalidIDError => e
103+
AWS::SessionStore::DynamoDB::InvalidIDError => e
104104
@config.error_handler.handle_error(e, env)
105105
end
106106
end

lib/aws/session_store/dynamo_db/railtie.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
# language governing permissions and limitations under the License.
1313

1414

15-
module AWS::DynamoDB::SessionStore
15+
module AWS::SessionStore::DynamoDB
1616
class Railtie < Rails::Railtie
1717
initializer 'aws-sessionstore-dynamodb-rack-middleware' do
18-
ActionDispatch::Session::DynamoDbStore = AWS::DynamoDB::SessionStore::RackMiddleware
18+
ActionDispatch::Session::DynamoDbStore = AWS::SessionStore::DynamoDB::RackMiddleware
1919
end
2020

2121
# Load all rake tasks

lib/aws/session_store/dynamo_db/table.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
require 'aws-sdk'
1515
require 'logger'
1616

17-
module AWS::DynamoDB::SessionStore
17+
module AWS::SessionStore::DynamoDB
1818
# This class provides a way to create and delete a session table.
1919
module Table
2020
module_function
@@ -50,7 +50,7 @@ def logger
5050
# @option (see Configuration#initialize)
5151
# @api private
5252
def load_config(options = {})
53-
AWS::DynamoDB::SessionStore::Configuration.new(options)
53+
AWS::SessionStore::DynamoDB::Configuration.new(options)
5454
end
5555

5656
# @return [Hash] Attribute settings for creating a session table.

lib/aws/session_store/dynamo_db/tasks/session_table.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace "db" do
1515
namespace "sessions" do
1616
desc 'Clean up Amazon DynamoDB session table'
1717
task :cleanup => :environment do |t|
18-
AWS::DynamoDB::SessionStore::GarbageCollection.collect_garbage
18+
AWS::SessionStore::DynamoDB::GarbageCollection.collect_garbage
1919
end
2020
end
2121
end
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
14+
15+
module AWS
16+
module SessionStore
17+
module DynamoDB
18+
VERSION = "0.5.0"
19+
end
20+
end
21+
end
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
class <%= name.camelize %> < ActiveRecord::Migration
22
def up
3-
AWS::DynamoDB::SessionStore::Table.create_table
3+
AWS::SessionStore::DynamoDB::Table.create_table
44
end
55

66
def down
7-
AWS::DynamoDB::SessionStore::Table.delete_table
7+
AWS::SessionStore::DynamoDB::Table.delete_table
88
end
99
end
1010

0 commit comments

Comments
 (0)