oversip-mod-postgresql 0.1.1 → 0.2.0

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.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  Name: oversip-mod-postgresql
2
2
  Maintainer: Iñaki Baz Castillo <ibc@aliax.net>
3
- Copyright (c) 2012 Iñaki Baz Castillo <ibc@aliax.net>
3
+ Copyright (c) 2013 Iñaki Baz Castillo <ibc@aliax.net>
4
4
 
5
5
 
6
6
  License: The MIT License
@@ -31,7 +31,24 @@ module OverSIP
31
31
 
32
32
  ::OverSIP::SystemCallbacks.on_started do
33
33
  log_info "Adding PostgreSQL connection pool (name: #{pool_name.inspect}, size: #{pool_size})..."
34
- @pools[pool_name] = ::EM::Synchrony::ConnectionPool.new(size: pool_size) do
34
+ @pools[pool_name] = Pool.new pool_size, options, block
35
+ end
36
+ end # def self.add_pool
37
+
38
+ def self.pool pool_name
39
+ pool = @pools[pool_name]
40
+ raise ::ArgumentError, "no pool with `name' #{pool_name.inspect}" unless pool
41
+ pool
42
+ end
43
+ class << self
44
+ alias :get_pool :pool
45
+ end
46
+
47
+
48
+ class Pool
49
+
50
+ def initialize pool_size, options, block
51
+ @em_synchrony_connectionpool = ::EM::Synchrony::ConnectionPool.new(size: pool_size) do
35
52
  # Avoid the hash to be modified by PG::EM::Client.
36
53
  options = options.clone
37
54
  # Force DB autoreconnect.
@@ -44,16 +61,24 @@ module OverSIP
44
61
  conn
45
62
  end
46
63
  end
47
- end
48
64
 
49
- def self.pool pool_name
50
- pool = @pools[pool_name]
51
- raise ::ArgumentError, "no pool with `name' #{pool_name.inspect}" unless pool
52
- pool
53
- end
54
- class << self
55
- alias :get_pool :pool
56
- end
65
+ def method_missing method, *args, &blk
66
+ @em_synchrony_connectionpool.__send__ method, *args, &blk
67
+ end
68
+
69
+ def query *args, &blk
70
+ # If we are not in the OverSIP Root Fiber then do nothing special.
71
+ if ::Fiber.current != ::OverSIP.root_fiber
72
+ @em_synchrony_connectionpool.__send__ :query, *args, &blk
73
+ # Otherwise run the query within a new Fiber.
74
+ else
75
+ ::Fiber.new do
76
+ @em_synchrony_connectionpool.__send__ :query, *args, &blk
77
+ end.resume
78
+ end
79
+ end
80
+
81
+ end # class Pool
57
82
 
58
83
  end # module Postgresql
59
84
 
@@ -4,8 +4,8 @@ module OverSIP
4
4
  module Postgresql
5
5
  module Version
6
6
  MAJOR = 0
7
- MINOR = 1
8
- TINY = 1
7
+ MINOR = 2
8
+ TINY = 0
9
9
  DEVEL = nil # Set to nil for stable releases.
10
10
  end
11
11
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oversip-mod-postgresql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-15 00:00:00.000000000 Z
12
+ date: 2013-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: oversip
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.3.0
21
+ version: 1.3.7
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 1.3.0
29
+ version: 1.3.7
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: em-pg-client
32
32
  requirement: !ruby/object:Gem::Requirement