isono 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{isono}
5
- s.version = "0.2.2"
5
+ s.version = "0.2.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["axsh Ltd.", "Masahiro Fujiwara"]
9
- s.date = %q{2011-06-02}
9
+ s.date = %q{2011-06-29}
10
10
  s.default_executable = %q{cli}
11
11
  s.email = ["dev@axsh.net", "m-fujiwara@axsh.net"]
12
12
  s.executables = ["cli"]
@@ -35,20 +35,31 @@ module Isono
35
35
 
36
36
  def self.pass(&blk)
37
37
  @instance.db_writer_thread.pass {
38
- @instance.establish_connection
39
- Sequel::DATABASES.first.transaction {
40
- blk.call
41
- }
38
+ process_single_tx(blk)
42
39
  }
43
40
  end
44
41
 
45
42
  def self.barrier(&blk)
46
43
  @instance.db_writer_thread.barrier {
47
- @instance.establish_connection
48
- Sequel::DATABASES.first.transaction {
44
+ process_single_tx(blk)
45
+ }
46
+ end
47
+
48
+ def self.process_single_tx(blk)
49
+ @instance.establish_connection
50
+ db = Sequel::DATABASES.first
51
+ begin
52
+ db.transaction {
49
53
  blk.call
50
54
  }
51
- }
55
+ rescue Sequel::DatabaseError, Sequel::DatabaseConnectionError => e
56
+ db.disconnect
57
+ raise e
58
+ end
59
+ end
60
+
61
+ def self.disconnected?
62
+ Sequel::DATABASES.first.nil? || Sequel::DATABASES.first.pool.size == 0
52
63
  end
53
64
 
54
65
  attr_reader :db_writer_thread
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Isono
4
- VERSION='0.2.2'
4
+ VERSION='0.2.3'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isono
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - axsh Ltd.
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-06-02 00:00:00 +09:00
19
+ date: 2011-06-29 00:00:00 +09:00
20
20
  default_executable: cli
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency