em-midori 0.1.10 → 0.1.11

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: d8f1764aac74f15dee72578e5dcc216e5afe34be
4
- data.tar.gz: 82d47b7a7b1a1eb822bd8ee3eba631d8527dcfb1
3
+ metadata.gz: 5026a74972dc1290c62c3fcc076c881164527ead
4
+ data.tar.gz: b93b97c69b109b6e28b9d05d46be862ff13447a5
5
5
  SHA512:
6
- metadata.gz: b27d592dbb83a83fd75e83825ecb24d8aed3548a641df1a97b4d659b461600c6db19cc421bb12bd1c3c19f250bd1fcb6012c2046838941a569f5d474313b73bb
7
- data.tar.gz: b32db3e3fc35dff0f2f4669c435fbfe03bb46a6f2fee5e8e74f587b8c50dca7f0f20a1fdeb2eb97f68a5364010008379d7434f13487711212f950b6828c4612e
6
+ metadata.gz: 885500b149d1153fededb86c8610be89361c2a3992d0f1a2ace635226121137f9beb5c32c9a519998ffeaff210f25b2a14d47176a5b031e487e8d36d7019d17d
7
+ data.tar.gz: 6d1563e43233277c2d41ef1bdb732e1131714449f67b0505d64777a6228d15804564b7e158b2a709cd8c9455588c0316ddd2a10b026bca213831a976f43b1e0c
@@ -30,20 +30,12 @@ class Midori::Connection
30
30
  end
31
31
 
32
32
  def send_data(data)
33
- if @monitor.writable?
34
- @socket.write_nonblock(data)
35
- else
36
- @data << data
37
- end
33
+ @monitor.writable? ? @socket.write_nonblock(data) : @data << data
38
34
  end
39
35
 
40
36
  def close_connection
41
- begin
42
- EventLoop.unregister @socket
43
- @socket.close
44
- rescue => e
45
- puts e
46
- end
37
+ EventLoop.unregister @socket
38
+ @socket.close
47
39
  end
48
40
 
49
41
  def close_connection_after_writing
@@ -0,0 +1,91 @@
1
+ safe_require 'sequel', 'gem install sequel'
2
+ require 'sequel/adapters/mysql2'
3
+
4
+ module Sequel
5
+ module Mysql2
6
+ class Database
7
+ # Execute the given SQL on the given connection. If the :type
8
+ # option is :select, yield the result of the query, otherwise
9
+ # yield the connection if a block is given.
10
+ def _execute(conn, sql, opts) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity
11
+ begin
12
+ # :nocov:
13
+ stream = opts[:stream]
14
+ if NativePreparedStatements
15
+ if (args = opts[:arguments])
16
+ args = args.map{|arg| bound_variable_value(arg)}
17
+ end
18
+
19
+ case sql
20
+ when ::Mysql2::Statement
21
+ stmt = sql
22
+ when Dataset
23
+ sql = sql.sql
24
+ close_stmt = true
25
+ stmt = conn.prepare(sql)
26
+ end
27
+ end
28
+
29
+ r = log_connection_yield((log_sql = opts[:log_sql]) ? sql + log_sql : sql, conn, args) do
30
+ if stmt
31
+ conn.query_options.merge!(cache_rows: true,
32
+ database_timezone: timezone,
33
+ application_timezone: Sequel.application_timezone,
34
+ stream: stream,
35
+ cast_booleans: convert_tinyint_to_bool)
36
+ stmt.execute(*args)
37
+ # :nocov:
38
+ else
39
+ socket = IO::open(conn.socket)
40
+ await(Promise.new do |resolve|
41
+ EventLoop.register(socket, :w) do
42
+ EventLoop.unregister(socket)
43
+ conn.query(sql,
44
+ database_timezone: timezone,
45
+ application_timezone: Sequel.application_timezone,
46
+ stream: stream,
47
+ async: true)
48
+ resolve.call
49
+ end
50
+ end)
51
+ await(Promise.new do |resolve|
52
+ EventLoop.register(socket, :r) do
53
+ EventLoop.unregister(socket)
54
+ resolve.call(conn.async_result)
55
+ end
56
+ end)
57
+ end
58
+ end
59
+
60
+ # :nocov:
61
+ if opts[:type] == :select
62
+ if r
63
+ if stream
64
+ begin
65
+ r2 = yield r
66
+ ensure
67
+ # If r2 is nil, it means the block did not exit normally,
68
+ # so the rest of the results must be drained to prevent
69
+ # "commands out of sync" errors.
70
+ r.each{} unless r2
71
+ end
72
+ else
73
+ yield r
74
+ end
75
+ end
76
+ elsif block_given?
77
+ yield conn
78
+ end
79
+ rescue ::Mysql2::Error => e
80
+ raise_error(e)
81
+ ensure
82
+ if stmt
83
+ conn.query_options.replace(conn.instance_variable_get(:@sequel_default_query_options))
84
+ stmt.close if close_stmt
85
+ end
86
+ # :nocov:
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
@@ -13,8 +13,8 @@ class Sequel::Postgres::Adapter
13
13
  socket_object = IO.for_fd(socket)
14
14
  await(Promise.new do |resolve|
15
15
  EventLoop.register(socket_object, :w) do
16
- EventLoop.unregister(socket_object)
17
- until is_busy
16
+ unless is_busy
17
+ EventLoop.unregister(socket_object)
18
18
  send_query(sql)
19
19
  resolve.call
20
20
  end
@@ -1,5 +1,5 @@
1
1
  # Midori Module
2
2
  module Midori
3
3
  # Current Version Code
4
- VERSION = '0.1.10'.freeze
4
+ VERSION = '0.1.11'.freeze
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-midori
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - HeckPsi Lab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-20 00:00:00.000000000 Z
11
+ date: 2017-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nio4r
@@ -78,6 +78,7 @@ files:
78
78
  - lib/midori/exception.rb
79
79
  - lib/midori/extension/file.rb
80
80
  - lib/midori/extension/hiredis.rb
81
+ - lib/midori/extension/sequel/mysql2.rb
81
82
  - lib/midori/extension/sequel/postgres.rb
82
83
  - lib/midori/middleware.rb
83
84
  - lib/midori/request.rb