rainbows-emtp 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/lib/rainbows/event_machine_thread_pool.rb +3 -1
- data/lib/rainbows/event_machine_thread_pool/client.rb +33 -30
- data/rainbows-emtp.gemspec +4 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12ec1b107844d2d9afdebb13afb37a108215539e
|
4
|
+
data.tar.gz: cdbb172e772e976a83b519d2d8ec5c95d1a6c36b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49e438d29dc3b33908232e97ef1873205210cbd84966289de085ac06ff37c943ba5c8baa0c9125058bf8e5709b85f56842764d90532e58f1c682c3ed47b2a369
|
7
|
+
data.tar.gz: 3614bba3b18a6fd41b6226f82b79ed37ccad5e6b0eba80a1a1e0308cf2538cf55d3571982220f0e3529a99bc6311560adbe00be1e195212a7a442679395daac6
|
data/Rakefile
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# -*- encoding: binary -*-
|
1
2
|
|
2
3
|
require 'rainbows'
|
3
4
|
|
@@ -6,8 +7,9 @@ module Rainbows::EventMachineThreadPool
|
|
6
7
|
extend Rainbows::PoolSize
|
7
8
|
include Rainbows::EventMachine
|
8
9
|
|
9
|
-
def init_worker_process
|
10
|
+
def init_worker_process(worker)
|
10
11
|
EM.threadpool_size = Rainbows::O[:pool_size]
|
12
|
+
logger.info "EventMachineThreadPool pool_size=#{Rainbows::O[:pool_size]}"
|
11
13
|
super
|
12
14
|
end
|
13
15
|
end
|
@@ -1,44 +1,47 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# -*- encoding: binary -*-
|
2
|
+
# :enddoc:
|
4
3
|
class Rainbows::EventMachineThreadPool::Client <
|
5
4
|
Rainbows::EventMachine::Client
|
6
5
|
|
6
|
+
def app_dispatch
|
7
|
+
EM.defer(method(:app_response), method(:response_write))
|
8
|
+
end
|
9
|
+
|
7
10
|
def app_call input
|
8
|
-
#
|
11
|
+
@deferred = true # we defer immediately
|
9
12
|
set_comm_inactivity_timeout 0
|
10
13
|
@env[RACK_INPUT] = input
|
11
14
|
@env[REMOTE_ADDR] = @_io.kgio_addr
|
12
15
|
@env[ASYNC_CALLBACK] = method(:write_async_response)
|
13
16
|
@env[ASYNC_CLOSE] = EM::DefaultDeferrable.new
|
14
17
|
@hp.hijack_setup(@env, @_io)
|
15
|
-
#
|
18
|
+
app_dispatch # must be implemented by subclass
|
19
|
+
end
|
16
20
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
@deferred = true
|
28
|
-
else
|
29
|
-
@deferred = nil
|
30
|
-
ev_write_response(status, headers, body, @hp.next?)
|
31
|
-
end
|
32
|
-
# Never ever crash any thread
|
33
|
-
rescue Exception => e
|
34
|
-
begin # Any user codes should be guarded
|
35
|
-
if handler = EM.instance_variable_get(:@error_handler)
|
36
|
-
handler.call(e)
|
37
|
-
end
|
38
|
-
rescue Exception
|
39
|
-
end
|
40
|
-
handle_error(e)
|
41
|
-
end
|
21
|
+
# this is only called in the master thread
|
22
|
+
def response_write(response)
|
23
|
+
if @hp.hijacked?
|
24
|
+
@deferred = nil
|
25
|
+
hijacked
|
26
|
+
elsif nil == response[0] || -1 == response[0]
|
27
|
+
@deferred = true
|
28
|
+
else
|
29
|
+
@deferred = nil
|
30
|
+
ev_write_response(*response, @hp.next?)
|
42
31
|
end
|
32
|
+
rescue => e
|
33
|
+
@deferred = nil
|
34
|
+
handle_error(e)
|
35
|
+
end
|
36
|
+
|
37
|
+
# fails-safe application dispatch, we absolutely cannot
|
38
|
+
# afford to fail or raise an exception (killing the thread)
|
39
|
+
# here because that could cause a deadlock and we'd leak FDs
|
40
|
+
def app_response
|
41
|
+
APP.call(@env.merge!(RACK_DEFAULTS))
|
42
|
+
rescue => e
|
43
|
+
Rainbows::Error.app(e) # we guarantee this does not raise
|
44
|
+
[ 500, {}, [] ]
|
43
45
|
end
|
46
|
+
|
44
47
|
end
|
data/rainbows-emtp.gemspec
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: rainbows-emtp 0.5.2 ruby lib
|
2
3
|
|
3
4
|
Gem::Specification.new do |s|
|
4
5
|
s.name = "rainbows-emtp"
|
5
|
-
s.version = "0.5.
|
6
|
+
s.version = "0.5.2"
|
6
7
|
|
7
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
9
|
s.authors = ["Lin Jen-Shin (godfat)"]
|
9
|
-
s.date = "2013-
|
10
|
+
s.date = "2013-09-17"
|
10
11
|
s.description = "EventMachineThreadPool model for Rainbows!"
|
11
12
|
s.email = ["godfat (XD) godfat.org"]
|
12
13
|
s.files = [
|
@@ -25,7 +26,7 @@ Gem::Specification.new do |s|
|
|
25
26
|
s.homepage = "https://github.com/godfat/rainbows-emtp"
|
26
27
|
s.licenses = ["Apache License 2.0"]
|
27
28
|
s.require_paths = ["lib"]
|
28
|
-
s.rubygems_version = "2.
|
29
|
+
s.rubygems_version = "2.1.3"
|
29
30
|
s.summary = "EventMachineThreadPool model for Rainbows!"
|
30
31
|
|
31
32
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rainbows-emtp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lin Jen-Shin (godfat)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbows
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.1.3
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: EventMachineThreadPool model for Rainbows!
|