sequel_transaction 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: adc27fce9062ff2ddb4f245e3bf08db21b6ad9fb
|
4
|
+
data.tar.gz: 06e5b0be2b5fa66d8fdd59a3b412cb31bbacfc18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 915df80cfe37565913346a68034b6b64ae9eeca0175ad12f36e102dd8612557cd64ffa7a1d4c446166ff693a0a2df3deecd4153494fca3bc2f2b95ae002b99ee
|
7
|
+
data.tar.gz: c9a65f3da49b80135b2873ed8e5ccec1514cc322f5b7bb292d7216c34b4e8bb78a4a68213e199e5ee82a82c7baf3ead8b9bacbd170a7a5d935d1f18cb551bf1f
|
data/README.md
CHANGED
@@ -25,18 +25,6 @@ Sidekiq.configure_server do |c|
|
|
25
25
|
end
|
26
26
|
```
|
27
27
|
|
28
|
-
It may be useful to ensure the transaction has been committed before queuing up
|
29
|
-
work by adding the following:
|
30
|
-
|
31
|
-
```ruby
|
32
|
-
Sidekiq.configure_client do |c|
|
33
|
-
c.client_middleware do |chain|
|
34
|
-
chain.add Sidekiq::Middleware::Client::AfterCommit,
|
35
|
-
connection: Sequel.connect('sqlite:///')
|
36
|
-
end
|
37
|
-
end
|
38
|
-
```
|
39
|
-
|
40
28
|
## Rack Wireup
|
41
29
|
|
42
30
|
To automatically wrap requests in a transaction, add the following:
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel_transaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- vyrak.bunleang@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -40,12 +40,10 @@ files:
|
|
40
40
|
- lib/sequel_transaction/rack.rb
|
41
41
|
- lib/sequel_transaction/rack/transaction.rb
|
42
42
|
- lib/sequel_transaction/sidekiq.rb
|
43
|
-
- lib/sequel_transaction/sidekiq/middleware/client/after_commit.rb
|
44
43
|
- lib/sequel_transaction/sidekiq/middleware/server/transaction.rb
|
45
44
|
- lib/sequel_transaction/version.rb
|
46
45
|
- sequel_transaction.gemspec
|
47
46
|
- spec/sequel_transaction/rack/transaction_spec.rb
|
48
|
-
- spec/sequel_transaction/sidekiq/middleware/client/after_commit_spec.rb
|
49
47
|
- spec/sequel_transaction/sidekiq/middleware/server/transaction_spec.rb
|
50
48
|
- spec/spec_helper.rb
|
51
49
|
homepage:
|
@@ -73,6 +71,5 @@ specification_version: 4
|
|
73
71
|
summary: Middlewares for Sequel transactions
|
74
72
|
test_files:
|
75
73
|
- spec/sequel_transaction/rack/transaction_spec.rb
|
76
|
-
- spec/sequel_transaction/sidekiq/middleware/client/after_commit_spec.rb
|
77
74
|
- spec/sequel_transaction/sidekiq/middleware/server/transaction_spec.rb
|
78
75
|
- spec/spec_helper.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module Sidekiq
|
2
|
-
module Middleware
|
3
|
-
module Client
|
4
|
-
class AfterCommit
|
5
|
-
def initialize(settings)
|
6
|
-
@connection = settings.fetch(:connection)
|
7
|
-
end
|
8
|
-
|
9
|
-
def call(*args)
|
10
|
-
@connection.after_commit do
|
11
|
-
yield
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'sequel_transaction/sidekiq'
|
3
|
-
|
4
|
-
describe Sidekiq::Middleware::Client::AfterCommit do
|
5
|
-
let(:table_name) { :sidekiq }
|
6
|
-
let(:dataset) { connection[table_name] }
|
7
|
-
let(:error) { RuntimeError.new }
|
8
|
-
|
9
|
-
subject { Sidekiq::Middleware::Client::AfterCommit.new connection: connection }
|
10
|
-
|
11
|
-
before do
|
12
|
-
connection.create_table table_name do
|
13
|
-
column :name, String, null: false
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
after { connection.drop_table table_name }
|
18
|
-
|
19
|
-
it 'defers yield until after committing a transaction' do
|
20
|
-
called = false
|
21
|
-
connection.transaction do
|
22
|
-
subject.call do
|
23
|
-
called = true
|
24
|
-
end
|
25
|
-
called.must_equal false
|
26
|
-
end
|
27
|
-
called.must_equal true
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'yields immediately without transaction' do
|
31
|
-
called = false
|
32
|
-
subject.call do
|
33
|
-
called = true
|
34
|
-
end
|
35
|
-
called.must_equal true
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'does not yield after failing to commit transaction' do
|
39
|
-
called = false
|
40
|
-
begin
|
41
|
-
connection.transaction do
|
42
|
-
subject.call do
|
43
|
-
called = true
|
44
|
-
end
|
45
|
-
raise
|
46
|
-
end
|
47
|
-
rescue
|
48
|
-
end
|
49
|
-
called.must_equal false
|
50
|
-
end
|
51
|
-
end
|