Skip to content

Commit

Permalink
Use autoload for internal modules
Browse files Browse the repository at this point in the history
It is prudent to not have people load the code they would never use.

Closes #19
  • Loading branch information
julik committed Feb 27, 2024
1 parent b386df9 commit 6e7f648
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [1.2.1] - 2024-02-22

- Use autoloading for internal modules. A user using Redis does not have to load the ActiveRecord storage backend, for example

## [1.2.0] - 2024-02-22

- Use memory locking in addition to DB locking in `ActiveRecordBackend`
Expand Down
17 changes: 9 additions & 8 deletions lib/idempo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
require "zlib"
require "set"

require_relative "idempo/active_record_backend"
require_relative "idempo/concurrent_request_error_app"
require_relative "idempo/malformed_key_error_app"
require_relative "idempo/memory_backend"
require_relative "idempo/redis_backend"
require_relative "idempo/request_fingerprint"
require_relative "idempo/memory_lock"
require_relative "idempo/version"
require "idempo/version"

class Idempo
autoload :ConcurrentRequestErrorApp, "idempo/concurrent_request_error_app"
autoload :MalformedKeyErrorApp, "idempo/malformed_key_error_app"
autoload :MemoryBackend, "idempo/memory_backend"
autoload :RedisBackend, "idempo/redis_backend"
autoload :ActiveRecordBackend, "idempo/active_record_backend"
autoload :RequestFingerprint, "idempo/request_fingerprint"
autoload :MemoryLock, "idempo/memory_lock"

DEFAULT_TTL_SECONDS = 30
SAVED_RESPONSE_BODY_SIZE_LIMIT = 4 * 1024 * 1024

Expand Down
2 changes: 0 additions & 2 deletions lib/idempo/concurrent_request_error_app.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require "json"

class Idempo::ConcurrentRequestErrorApp
RETRY_AFTER_SECONDS = 2.to_s

Expand Down
2 changes: 0 additions & 2 deletions lib/idempo/malformed_key_error_app.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require "json"

class Idempo::MalformedKeyErrorApp
def self.call(env)
res = {
Expand Down
2 changes: 1 addition & 1 deletion lib/idempo/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

class Idempo
VERSION = "1.2.0"
VERSION = "1.2.1"
end

0 comments on commit 6e7f648

Please sign in to comment.