oversip-mod-mysql 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 CHANGED
@@ -84,6 +84,22 @@ end
84
84
  ```
85
85
 
86
86
 
87
+ ## Notes
88
+
89
+ ### SQL queries in events others than OverSIP provides
90
+
91
+ 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):
92
+
93
+ ```
94
+ EM.add_periodic_timer(2) do
95
+ Fiber.new do
96
+ pool = OverSIP::M::Mysql.pool(:my_db)
97
+ rows = pool.query "SELECT * FROM users"
98
+ log_info "online users: #{rows.inspect}"
99
+ end
100
+ end
101
+ ```
102
+
87
103
  ## Limitations
88
104
 
89
105
  [mysql2](https://github.com/brianmario/mysql2) driver has auto reconnection support (which is forced by `oversip-mod-mysql` by setting the field `options[:reconnect] => true`). Unfortunatelly the auto reconnect feature of `mysql2` driver is blocking which means that, in case the MySQL server goes down, OverSIP will get frozen during the auto reconnection attempt.
@@ -19,6 +19,9 @@ module OverSIP
19
19
  def self.add_pool options
20
20
  raise ::ArgumentError, "`options' must be a Hash" unless options.is_a? ::Hash
21
21
 
22
+ # Avoid the hash to be modified internally.
23
+ options = options.clone
24
+ # Delete options not existing in mysql2.
22
25
  pool_name = options.delete(:pool_name)
23
26
  pool_size = options.delete(:pool_size) || DEFAULT_POOL_SIZE
24
27
 
@@ -31,11 +34,11 @@ module OverSIP
31
34
  log_info "Adding MySQL connection pool (name: #{pool_name.inspect}, size: #{pool_size})..."
32
35
  @pools[pool_name] = ::EM::Synchrony::ConnectionPool.new(size: pool_size) do
33
36
  # Avoid the hash to be modified internally.
34
- new_options = options.clone
37
+ options = options.clone
35
38
  # Force DB autoreconnect.
36
- new_options[:reconnect] = true
39
+ options[:reconnect] = true
37
40
 
38
- conn = ::Mysql2::EM::Client.new(new_options)
41
+ conn = ::Mysql2::EM::Client.new(options)
39
42
 
40
43
  # Call the given block by passing conn as argument.
41
44
  block.call(conn) if block
@@ -5,7 +5,7 @@ module OverSIP
5
5
  module Version
6
6
  MAJOR = 0
7
7
  MINOR = 1
8
- TINY = 0
8
+ TINY = 1
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-mysql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
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: 2012-10-04 00:00:00.000000000 Z
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: &7556920 !ruby/object:Gem::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: *7556920
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: mysql2
27
- requirement: &7556360 !ruby/object:Gem::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.3.11
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *7556360
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.3.11
36
46
  description: oversip-mod-mysql provides an easy to use MySQL connector for OverSIP
37
47
  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.11
79
+ rubygems_version: 1.8.23
70
80
  signing_key:
71
81
  specification_version: 3
72
82
  summary: MySQL connector module for OverSIP