io_request 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +29 -28
- data/io_request.gemspec +37 -37
- data/lib/io_request/client.rb +6 -6
- data/lib/io_request/utility.rb +8 -3
- data/lib/io_request/version.rb +4 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bc70dc523aa523749a9ff7ced4fb1e59243a70ab963026b76c0feada184adad
|
4
|
+
data.tar.gz: fd2d048ddf79f0102bbc39ab72ad98529b090d40a2f681b72bb14d2149bea241
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e348c7d960286264707730c07f46ed6de58edd8b27653271aa4b76f87718c1ca623364299a409d4179c71083158c076d9658dcfe7a7f1ef6b62610eae797da3
|
7
|
+
data.tar.gz: 5d01d75cfdd3eea6b39b1e1a74556bd260ded06d699f72cbe22f1812d5680a3d4621170116d2bfc7700d0c6a8793c1e34959dd039fd2bb94566abae439816950
|
data/Gemfile.lock
CHANGED
@@ -1,28 +1,29 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
io_request (1.
|
5
|
-
json (~> 2.0)
|
6
|
-
logger (~> 1.4)
|
7
|
-
timeout-extensions (~> 0.1.1)
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
json (2.
|
13
|
-
logger (1.4.1)
|
14
|
-
minitest (5.13.0)
|
15
|
-
rake (
|
16
|
-
timeout-extensions (0.1.1)
|
17
|
-
|
18
|
-
PLATFORMS
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
io_request (1.2.0)
|
5
|
+
json (~> 2.0)
|
6
|
+
logger (~> 1.4)
|
7
|
+
timeout-extensions (~> 0.1.1)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
json (2.3.0)
|
13
|
+
logger (1.4.1)
|
14
|
+
minitest (5.13.0)
|
15
|
+
rake (13.0.1)
|
16
|
+
timeout-extensions (0.1.1)
|
17
|
+
|
18
|
+
PLATFORMS
|
19
|
+
ruby
|
20
|
+
x64-mingw32
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
bundler (~> 2.0)
|
24
|
+
io_request!
|
25
|
+
minitest (~> 5.0)
|
26
|
+
rake (~> 13.0)
|
27
|
+
|
28
|
+
BUNDLED WITH
|
29
|
+
2.0.2
|
data/io_request.gemspec
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
lib = File.expand_path("lib", __dir__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require "io_request/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |spec|
|
6
|
-
spec.name = "io_request"
|
7
|
-
spec.version = IORequest::VERSION
|
8
|
-
spec.authors = ["Fizvlad"]
|
9
|
-
spec.email = ["fizvlad@mail.ru"]
|
10
|
-
|
11
|
-
spec.summary = "Small gem to create JSON request/response type of connection over IO object"
|
12
|
-
spec.homepage = "https://github.com/fizvlad/io-request-rb"
|
13
|
-
spec.license = "MIT"
|
14
|
-
|
15
|
-
spec.required_ruby_version = ">=2.3.1"
|
16
|
-
|
17
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
-
spec.metadata["source_code_uri"] = "https://github.com/fizvlad/io-request-rb"
|
19
|
-
spec.metadata["changelog_uri"] = "https://github.com/fizvlad/io-request-rb/releases"
|
20
|
-
|
21
|
-
# Specify which files should be added to the gem when it is released.
|
22
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
-
end
|
26
|
-
spec.bindir = "exe"
|
27
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
-
spec.require_paths = ["lib"]
|
29
|
-
|
30
|
-
spec.add_development_dependency "bundler", "~> 2.0"
|
31
|
-
spec.add_development_dependency "rake", "~>
|
32
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
33
|
-
|
34
|
-
spec.add_runtime_dependency "logger", "~>1.4"
|
35
|
-
spec.add_runtime_dependency "timeout-extensions", "~>0.1.1"
|
36
|
-
spec.add_runtime_dependency "json", "~>2.0"
|
37
|
-
end
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "io_request/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "io_request"
|
7
|
+
spec.version = IORequest::VERSION
|
8
|
+
spec.authors = ["Fizvlad"]
|
9
|
+
spec.email = ["fizvlad@mail.ru"]
|
10
|
+
|
11
|
+
spec.summary = "Small gem to create JSON request/response type of connection over IO object"
|
12
|
+
spec.homepage = "https://github.com/fizvlad/io-request-rb"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.required_ruby_version = ">=2.3.1"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/fizvlad/io-request-rb"
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/fizvlad/io-request-rb/releases"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
31
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
32
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
33
|
+
|
34
|
+
spec.add_runtime_dependency "logger", "~>1.4"
|
35
|
+
spec.add_runtime_dependency "timeout-extensions", "~>0.1.1"
|
36
|
+
spec.add_runtime_dependency "json", "~>2.0"
|
37
|
+
end
|
data/lib/io_request/client.rb
CHANGED
@@ -33,7 +33,7 @@ module IORequest
|
|
33
33
|
# @option options [Integer, Float] timeout timeout for {Request#join}.
|
34
34
|
#
|
35
35
|
# @yieldparam request [Response] response for request.
|
36
|
-
#
|
36
|
+
#
|
37
37
|
# @return [Request]
|
38
38
|
def request(data: {}, sync: false, timeout: nil, &block)
|
39
39
|
req = Request.new(data)
|
@@ -79,12 +79,12 @@ module IORequest
|
|
79
79
|
# Handle incoming request.
|
80
80
|
def handle_in_request(req)
|
81
81
|
IORequest.debug("Handling request ##{req.id}", prog_name)
|
82
|
-
in_thread do
|
82
|
+
in_thread(name: "request_handler") do
|
83
83
|
responder = find_responder(req)
|
84
84
|
data = nil
|
85
85
|
data = begin
|
86
86
|
if responder
|
87
|
-
responder.call(req)
|
87
|
+
responder.call(req, self)
|
88
88
|
else
|
89
89
|
IORequest.warn "Responder not found!"
|
90
90
|
nil
|
@@ -112,7 +112,7 @@ module IORequest
|
|
112
112
|
# If block is not provided it's totally ok
|
113
113
|
block = @out_requests.delete(req)
|
114
114
|
if block
|
115
|
-
in_thread do
|
115
|
+
in_thread(name: "response_handle") do
|
116
116
|
begin
|
117
117
|
block.call(res)
|
118
118
|
rescue Exception => e
|
@@ -131,12 +131,12 @@ module IORequest
|
|
131
131
|
break
|
132
132
|
end
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
result
|
136
136
|
end
|
137
137
|
|
138
138
|
# Send data.
|
139
|
-
#
|
139
|
+
#
|
140
140
|
# @param [Hash]
|
141
141
|
def send(data)
|
142
142
|
IORequest.debug("Sending hash: #{data.inspect}", prog_name)
|
data/lib/io_request/utility.rb
CHANGED
@@ -24,8 +24,12 @@ module IORequest
|
|
24
24
|
|
25
25
|
# Runs block with provided arguments forwarded as arguments in separate thread.
|
26
26
|
#
|
27
|
+
# All the inline args will be passed to block.
|
28
|
+
#
|
29
|
+
# @param thread_name [String] thread name.
|
30
|
+
#
|
27
31
|
# @return [Thread]
|
28
|
-
def in_thread(*args, &block)
|
32
|
+
def in_thread(*args, name: nil, &block)
|
29
33
|
@_MultiThread_threads ||= []
|
30
34
|
@_MultiThread_mutex ||= Mutex.new
|
31
35
|
# Synchronizing addition/deletion of new threads. That's important
|
@@ -40,14 +44,15 @@ module IORequest
|
|
40
44
|
end
|
41
45
|
end
|
42
46
|
@_MultiThread_threads << new_thread
|
47
|
+
new_thread.name = name if name
|
43
48
|
new_thread
|
44
|
-
end
|
49
|
+
end
|
45
50
|
end
|
46
51
|
|
47
52
|
# For each running thread.
|
48
53
|
def each_thread(&block)
|
49
54
|
@_MultiThread_threads ||= []
|
50
|
-
|
55
|
+
|
51
56
|
@_MultiThread_threads.each(&block)
|
52
57
|
end
|
53
58
|
|
data/lib/io_request/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
module IORequest
|
2
|
-
# Gem version.
|
3
|
-
VERSION = "1.
|
4
|
-
end
|
1
|
+
module IORequest
|
2
|
+
# Gem version.
|
3
|
+
VERSION = "1.2.0"
|
4
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io_request
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fizvlad
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '13.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '13.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|