async-sequel 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/README.md +72 -0
- data/Rakefile +6 -0
- data/async-sequel.gemspec +28 -0
- data/examples/enumerate/rubygems.rb +26 -0
- data/lib/async/sequel.rb +21 -0
- data/lib/async/sequel/connection_pool/fibered.rb +156 -0
- data/lib/async/sequel/postgres/adapter.rb +112 -0
- data/lib/async/sequel/postgres/database.rb +68 -0
- data/lib/async/sequel/version.rb +25 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 376913405c62208c2fbdf5be61966e104319788e07d966237321c9e60f836348
|
4
|
+
data.tar.gz: 3f9bcebfec1290454dda560f297a7e2a2ee002521eb4561846a040657df76ead
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 80f7ad5fbb1076f248852517d50355e1daecb7c76b037ff3bcbbfc1443e4b228c9e2397c3e74461759fe87b632aebdbe14eafedc51eb3ec3ea8d09d5e5a6af95
|
7
|
+
data.tar.gz: eaefce0c7cc084c8151d83a2ed6867cc276ebb15ed5e53ca1dee06f62b6e21c4fa2ff70229e9bfe6071c8cbb9ce90b855b8a0d90d7fb9fee0ab29635d4c67b57
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# Async::Sequel
|
2
|
+
|
3
|
+
**Experimental** support for asynchronous sequel.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
To add it to your existing project:
|
8
|
+
|
9
|
+
$ bundle add sequel
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
require 'async'
|
15
|
+
require 'sequel'
|
16
|
+
|
17
|
+
require 'async/sequel/postgres/database'
|
18
|
+
require 'async/sequel/connection_pool/fibered'
|
19
|
+
|
20
|
+
Async do
|
21
|
+
db = Sequel.connect(
|
22
|
+
adapter: Async::Sequel::Postgres::Database,
|
23
|
+
host: "localhost", database: "rubygems",
|
24
|
+
pool_class: Async::Sequel::ConnectionPool::Fibered
|
25
|
+
)
|
26
|
+
|
27
|
+
query = db.select{pg_sleep(1)}
|
28
|
+
|
29
|
+
10.times do
|
30
|
+
Async do |task|
|
31
|
+
while true
|
32
|
+
# These queries will all run concurrently.
|
33
|
+
Async.logger.info("query", query.to_a)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
ensure
|
38
|
+
db&.disconnect
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
1. Fork it
|
45
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
46
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
47
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
48
|
+
5. Create new Pull Request
|
49
|
+
|
50
|
+
## License
|
51
|
+
|
52
|
+
Released under the MIT license.
|
53
|
+
|
54
|
+
Copyright, 2019, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
55
|
+
|
56
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
57
|
+
of this software and associated documentation files (the "Software"), to deal
|
58
|
+
in the Software without restriction, including without limitation the rights
|
59
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
60
|
+
copies of the Software, and to permit persons to whom the Software is
|
61
|
+
furnished to do so, subject to the following conditions:
|
62
|
+
|
63
|
+
The above copyright notice and this permission notice shall be included in
|
64
|
+
all copies or substantial portions of the Software.
|
65
|
+
|
66
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
67
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
68
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
69
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
70
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
71
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
72
|
+
THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
require_relative 'lib/async/sequel/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "async-sequel"
|
6
|
+
spec.version = Async::Sequel::VERSION
|
7
|
+
spec.authors = ["Samuel Williams"]
|
8
|
+
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
9
|
+
|
10
|
+
spec.summary = %q{Asynchronous adaptors for Sequel.}
|
11
|
+
spec.homepage = "https://github.com/socketry/async-sequel"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
# Specify which files should be added to the gem when it is released.
|
15
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
16
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
17
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
end
|
19
|
+
|
20
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
22
|
+
|
23
|
+
spec.add_dependency "sequel"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
require 'async'
|
3
|
+
|
4
|
+
require 'sequel'
|
5
|
+
require_relative '../../lib/async/sequel/postgres/database'
|
6
|
+
require_relative '../../lib/async/sequel/connection_pool/fibered'
|
7
|
+
|
8
|
+
Async.logger.info!
|
9
|
+
|
10
|
+
Async do
|
11
|
+
db = Sequel.connect(adapter: Async::Sequel::Postgres::Database, host: "localhost", user: "samuel", database: "rubygems", pool_class: Async::Sequel::ConnectionPool::Fibered)
|
12
|
+
|
13
|
+
query = db.select{pg_sleep(1)}
|
14
|
+
|
15
|
+
10.times do
|
16
|
+
Async do |task|
|
17
|
+
while true
|
18
|
+
Async.logger.info("query", query.to_a)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
ensure
|
23
|
+
db&.disconnect
|
24
|
+
end
|
25
|
+
|
26
|
+
Async.logger.info("Done")
|
data/lib/async/sequel.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require_relative "sequel/version"
|
@@ -0,0 +1,156 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'async/notification'
|
24
|
+
|
25
|
+
require 'sequel/connection_pool'
|
26
|
+
|
27
|
+
module Async
|
28
|
+
module Sequel
|
29
|
+
module ConnectionPool
|
30
|
+
class Fibered < ::Sequel::ConnectionPool
|
31
|
+
def initialize(database, limit: nil, **options)
|
32
|
+
super(database, **options)
|
33
|
+
|
34
|
+
@database = database
|
35
|
+
@options = options
|
36
|
+
|
37
|
+
@resources = []
|
38
|
+
@available = Async::Notification.new
|
39
|
+
|
40
|
+
@limit = limit
|
41
|
+
@active = 0
|
42
|
+
end
|
43
|
+
|
44
|
+
attr :resources
|
45
|
+
|
46
|
+
def hold(server = nil, &block)
|
47
|
+
acquire(&block)
|
48
|
+
end
|
49
|
+
|
50
|
+
def disconnect(server = nil)
|
51
|
+
self.close
|
52
|
+
end
|
53
|
+
|
54
|
+
def servers
|
55
|
+
[:default]
|
56
|
+
end
|
57
|
+
|
58
|
+
def size
|
59
|
+
@active
|
60
|
+
end
|
61
|
+
|
62
|
+
def max_size
|
63
|
+
@limit
|
64
|
+
end
|
65
|
+
|
66
|
+
def empty?
|
67
|
+
@resources.empty?
|
68
|
+
end
|
69
|
+
|
70
|
+
def acquire
|
71
|
+
resource = wait_for_resource
|
72
|
+
|
73
|
+
return resource unless block_given?
|
74
|
+
|
75
|
+
begin
|
76
|
+
yield resource
|
77
|
+
ensure
|
78
|
+
release(resource)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Make the resource resources and let waiting tasks know that there is something resources.
|
83
|
+
def release(resource)
|
84
|
+
# A resource that is not good should also not be reusable.
|
85
|
+
# unless resource.closed?
|
86
|
+
reuse(resource)
|
87
|
+
# else
|
88
|
+
# retire(resource)
|
89
|
+
# end
|
90
|
+
end
|
91
|
+
|
92
|
+
def close
|
93
|
+
@resources.each(&:close)
|
94
|
+
@resources.clear
|
95
|
+
|
96
|
+
@active = 0
|
97
|
+
end
|
98
|
+
|
99
|
+
def to_s
|
100
|
+
"\#<#{self.class} resources=#{resources.size} limit=#{@limit}>"
|
101
|
+
end
|
102
|
+
|
103
|
+
protected
|
104
|
+
|
105
|
+
def reuse(resource)
|
106
|
+
Async.logger.debug(self) {"Reuse #{resource}"}
|
107
|
+
|
108
|
+
@resources << resource
|
109
|
+
|
110
|
+
@available.signal
|
111
|
+
end
|
112
|
+
|
113
|
+
def retire(resource)
|
114
|
+
Async.logger.debug(self) {"Retire #{resource}"}
|
115
|
+
|
116
|
+
@active -= 1
|
117
|
+
|
118
|
+
resource.close
|
119
|
+
|
120
|
+
@available.signal
|
121
|
+
end
|
122
|
+
|
123
|
+
def wait_for_resource
|
124
|
+
# If we fail to create a resource (below), we will end up waiting for one to become resources.
|
125
|
+
until resource = available_resource
|
126
|
+
@available.wait
|
127
|
+
end
|
128
|
+
|
129
|
+
Async.logger.debug(self) {"Wait for resource #{resource}"}
|
130
|
+
|
131
|
+
return resource
|
132
|
+
end
|
133
|
+
|
134
|
+
def available_resource
|
135
|
+
while resource = @resources.pop
|
136
|
+
# if resource.connected?
|
137
|
+
return resource
|
138
|
+
# else
|
139
|
+
# retire(resource)
|
140
|
+
# end
|
141
|
+
end
|
142
|
+
|
143
|
+
if @limit.nil? or @active < @limit
|
144
|
+
Async.logger.debug(self) {"No resources resources, allocating new one..."}
|
145
|
+
|
146
|
+
@active += 1
|
147
|
+
|
148
|
+
return make_new(:default)
|
149
|
+
end
|
150
|
+
|
151
|
+
return nil
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require 'async/wrapper'
|
22
|
+
|
23
|
+
require 'sequel/adapters/postgres'
|
24
|
+
|
25
|
+
module Async
|
26
|
+
module Sequel
|
27
|
+
module Postgres
|
28
|
+
class Adapter < Wrapper
|
29
|
+
def initialize(database, connection_specification, reactor = nil)
|
30
|
+
@connection = ::Sequel::Postgres::Adapter.connect_start(connection_specification)
|
31
|
+
|
32
|
+
@db = database
|
33
|
+
@connection.instance_variable_set(:@db, database)
|
34
|
+
@connection.instance_variable_set(:@prepared_statements, {})
|
35
|
+
|
36
|
+
super(@connection.socket_io, reactor)
|
37
|
+
|
38
|
+
status = @connection.connect_poll
|
39
|
+
|
40
|
+
while true
|
41
|
+
if status == PG::PGRES_POLLING_FAILED
|
42
|
+
raise PG::Error.new(@connection.error_message)
|
43
|
+
elsif status == PG::PGRES_POLLING_READING
|
44
|
+
self.wait_readable
|
45
|
+
elsif(status == PG::PGRES_POLLING_WRITING)
|
46
|
+
self.wait_writable
|
47
|
+
elsif status == PG::PGRES_POLLING_OK
|
48
|
+
break
|
49
|
+
end
|
50
|
+
|
51
|
+
status = @connection.connect_poll
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def async_exec(*args)
|
56
|
+
@connection.send_query(*args)
|
57
|
+
last_result = result = true
|
58
|
+
|
59
|
+
Async.logger.info(self) {args}
|
60
|
+
|
61
|
+
while true
|
62
|
+
wait_readable
|
63
|
+
|
64
|
+
@connection.consume_input
|
65
|
+
|
66
|
+
while @connection.is_busy == false
|
67
|
+
if result = @connection.get_result
|
68
|
+
last_result = result
|
69
|
+
|
70
|
+
yield result if block_given?
|
71
|
+
else
|
72
|
+
return last_result
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
ensure
|
77
|
+
@connection.get_result until result.nil?
|
78
|
+
end
|
79
|
+
|
80
|
+
alias exec async_exec
|
81
|
+
alias exec_params exec
|
82
|
+
|
83
|
+
# Execute the given SQL with this connection. If a block is given,
|
84
|
+
# yield the results, otherwise, return the number of changed rows.
|
85
|
+
def execute(sql, args=nil)
|
86
|
+
args = args.map{|v| @db.bound_variable_arg(v, self)} if args
|
87
|
+
q = check_disconnect_errors{execute_query(sql, args)}
|
88
|
+
begin
|
89
|
+
block_given? ? yield(q) : q.cmd_tuples
|
90
|
+
ensure
|
91
|
+
q.clear if q && q.respond_to?(:clear)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Return the PGResult containing the query results.
|
96
|
+
def execute_query(sql, args)
|
97
|
+
@db.log_connection_yield(sql, self, args){args ? self.async_exec(sql, args) : self.async_exec(sql)}
|
98
|
+
end
|
99
|
+
|
100
|
+
def respond_to?(*args)
|
101
|
+
@connection.respond_to?(*args)
|
102
|
+
end
|
103
|
+
|
104
|
+
def method_missing(*args, &block)
|
105
|
+
# Async.logger.info(self) {args}
|
106
|
+
|
107
|
+
@connection.send(*args, &block)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
require_relative 'adapter'
|
22
|
+
|
23
|
+
require 'sequel/adapters/postgres'
|
24
|
+
|
25
|
+
module Async
|
26
|
+
module Sequel
|
27
|
+
module Postgres
|
28
|
+
class Database < ::Sequel::Postgres::Database
|
29
|
+
def connect(server)
|
30
|
+
opts = server_opts(server)
|
31
|
+
|
32
|
+
connection_params = {
|
33
|
+
:host => opts[:host],
|
34
|
+
:port => opts[:port],
|
35
|
+
:dbname => opts[:database],
|
36
|
+
:user => opts[:user],
|
37
|
+
:password => opts[:password],
|
38
|
+
:connect_timeout => opts[:connect_timeout] || 20,
|
39
|
+
:sslmode => opts[:sslmode],
|
40
|
+
:sslrootcert => opts[:sslrootcert]
|
41
|
+
}.delete_if { |key, value| blank_object?(value) }
|
42
|
+
|
43
|
+
connection_params.merge!(opts[:driver_options]) if opts[:driver_options]
|
44
|
+
conn = Adapter.new(self, opts[:conn_str] || connection_params)
|
45
|
+
|
46
|
+
if receiver = opts[:notice_receiver]
|
47
|
+
conn.set_notice_receiver(&receiver)
|
48
|
+
end
|
49
|
+
|
50
|
+
if conn.respond_to?(:type_map_for_queries=) && defined?(self::PG_QUERY_TYPE_MAP)
|
51
|
+
conn.type_map_for_queries = self::PG_QUERY_TYPE_MAP
|
52
|
+
end
|
53
|
+
|
54
|
+
if encoding = opts[:encoding] || opts[:charset]
|
55
|
+
if conn.respond_to?(:set_client_encoding)
|
56
|
+
conn.set_client_encoding(encoding)
|
57
|
+
else
|
58
|
+
conn.async_exec("set client_encoding to '#{encoding}'")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
connection_configuration_sqls(opts).each{|sql| conn.execute(sql)}
|
63
|
+
conn
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
8
|
+
# furnished to do so, subject to the following conditions:
|
9
|
+
#
|
10
|
+
# The above copyright notice and this permission notice shall be included in
|
11
|
+
# all copies or substantial portions of the Software.
|
12
|
+
#
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
# THE SOFTWARE.
|
20
|
+
|
21
|
+
module Async
|
22
|
+
module Sequel
|
23
|
+
VERSION = "0.1.0"
|
24
|
+
end
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: async-sequel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Samuel Williams
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sequel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- samuel.williams@oriontransfer.co.nz
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- async-sequel.gemspec
|
83
|
+
- examples/enumerate/rubygems.rb
|
84
|
+
- lib/async/sequel.rb
|
85
|
+
- lib/async/sequel/connection_pool/fibered.rb
|
86
|
+
- lib/async/sequel/postgres/adapter.rb
|
87
|
+
- lib/async/sequel/postgres/database.rb
|
88
|
+
- lib/async/sequel/version.rb
|
89
|
+
homepage: https://github.com/socketry/async-sequel
|
90
|
+
licenses:
|
91
|
+
- MIT
|
92
|
+
metadata: {}
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubygems_version: 3.0.4
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Asynchronous adaptors for Sequel.
|
112
|
+
test_files: []
|