-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from basecamp/sqlite
Run solid_queue with SQLite
- Loading branch information
Showing
8 changed files
with
63 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
module SqliteImmediateTransactions | ||
def begin_db_transaction | ||
log("begin immediate transaction", "TRANSACTION") do | ||
with_raw_connection(allow_retry: true, materialize_transactions: false) do |conn| | ||
conn.transaction(:immediate) | ||
end | ||
end | ||
end | ||
end | ||
|
||
module SQLite3Configuration | ||
private | ||
def configure_connection | ||
super | ||
|
||
if @config[:retries] | ||
retries = self.class.type_cast_config_to_integer(@config[:retries]) | ||
raw_connection.busy_handler do |count| | ||
(count <= retries).tap { |result| sleep count * 0.001 if result } | ||
end | ||
end | ||
end | ||
end | ||
|
||
ActiveSupport.on_load :active_record do | ||
if defined?(ActiveRecord::ConnectionAdapters::SQLite3Adapter) | ||
ActiveRecord::ConnectionAdapters::SQLite3Adapter.prepend SqliteImmediateTransactions | ||
ActiveRecord::ConnectionAdapters::SQLite3Adapter.prepend SQLite3Configuration | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters