oversip-mod-postgresql 0.1.0 → 0.1.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.
- data/README.md +16 -0
- data/lib/oversip-mod-postgresql.rb +6 -3
- data/lib/oversip-mod-postgresql/version.rb +1 -1
- metadata +17 -7
data/README.md
CHANGED
@@ -83,6 +83,22 @@ rescue ::PG::Error => e
|
|
83
83
|
end
|
84
84
|
```
|
85
85
|
|
86
|
+
## Notes
|
87
|
+
|
88
|
+
### SQL queries in events others than OverSIP provides
|
89
|
+
|
90
|
+
If you want to place a SQL query within an event different than those provided by OverSIP (i.e. within a EventMachine `add_timer` or `next_tick` callback) then you need to create a Fiber and place the SQL query there (otherwise "can't yield from root fiber" error will occur):
|
91
|
+
|
92
|
+
```
|
93
|
+
EM.add_periodic_timer(2) do
|
94
|
+
Fiber.new do
|
95
|
+
pool = OverSIP::M::Postgresql.pool(:my_db)
|
96
|
+
rows = pool.query "SELECT * FROM users"
|
97
|
+
log_info "online users: #{rows.inspect}"
|
98
|
+
end
|
99
|
+
end
|
100
|
+
```
|
101
|
+
|
86
102
|
|
87
103
|
## Dependencies
|
88
104
|
|
@@ -18,6 +18,9 @@ module OverSIP
|
|
18
18
|
def self.add_pool options
|
19
19
|
raise ::ArgumentError, "`options' must be a Hash" unless options.is_a? ::Hash
|
20
20
|
|
21
|
+
# Avoid the hash to be modified internally.
|
22
|
+
options = options.clone
|
23
|
+
# Delete options not existing in pg.
|
21
24
|
pool_name = options.delete(:pool_name)
|
22
25
|
pool_size = options.delete(:pool_size) || DEFAULT_POOL_SIZE
|
23
26
|
|
@@ -30,11 +33,11 @@ module OverSIP
|
|
30
33
|
log_info "Adding PostgreSQL connection pool (name: #{pool_name.inspect}, size: #{pool_size})..."
|
31
34
|
@pools[pool_name] = ::EM::Synchrony::ConnectionPool.new(size: pool_size) do
|
32
35
|
# Avoid the hash to be modified by PG::EM::Client.
|
33
|
-
|
36
|
+
options = options.clone
|
34
37
|
# Force DB autoreconnect.
|
35
|
-
|
38
|
+
options[:async_autoreconnect] = true
|
36
39
|
|
37
|
-
conn = ::PG::EM::Client.new(
|
40
|
+
conn = ::PG::EM::Client.new(options)
|
38
41
|
|
39
42
|
# Call the given block by passing conn as argument.
|
40
43
|
block.call(conn) if block
|
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.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: oversip
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 1.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.3.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: em-pg-client
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,7 +37,12 @@ dependencies:
|
|
32
37
|
version: 0.2.1
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.2.1
|
36
46
|
description: oversip-mod-postgresql provides an easy to use PostgreSQL connector for
|
37
47
|
OverSIP proxy.
|
38
48
|
email:
|
@@ -66,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
76
|
version: '0'
|
67
77
|
requirements: []
|
68
78
|
rubyforge_project:
|
69
|
-
rubygems_version: 1.8.
|
79
|
+
rubygems_version: 1.8.23
|
70
80
|
signing_key:
|
71
81
|
specification_version: 3
|
72
82
|
summary: PostgreSQL connector module for OverSIP
|