riser 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef14df0b3e4899c0d573754bdc7071bd88ee89103d51d51d547a200bf9d305a5
4
- data.tar.gz: f3784e9ec64b88fe4ca68a51ceeffba1af2ba1c4e6fa464a555a76da27c6c98f
3
+ metadata.gz: b9ae7fbe0d87eb7546bcd3df41adb101c0c66bb964e07de7d3658cf63d397562
4
+ data.tar.gz: 288ab38bbd42a41f31a399f12289adf4cdc8ad700ac649a09fea2ec593a2b4f3
5
5
  SHA512:
6
- metadata.gz: 190ba65ce5b250938ebd92ae5cebf8a96b2995a19221e8c8a39ad2024e18f7c24f1cb07570d2c2c60374363572c79083a2ca50d16fb503581192c1b0ee142142
7
- data.tar.gz: 97f9c5de7034224540e9c4e118e45a6d99179a143d2cd2ce375f0e4cf53a8c0a641b5ec1a43667da71ad75709a16395059ff69019c8a86f971862f941dbe1ace
6
+ metadata.gz: 98f72efdfda6c5eee8e7adcb0b3a0d5d6ceca0df6f73b1bd544b3eae535f62e671b76a29074bd60c9992943852e89d294e02b38788496e97bf0f66c276462dd4
7
+ data.tar.gz: e8f52a3f99f42d6bb4e7c05a260165a82d4712669490f9717c95e87639af9551c3aa0288102a813a212897d0f6f8b83465255d0eebdda89f69ead6d7e7757795
@@ -4,6 +4,7 @@ require 'riser/version'
4
4
 
5
5
  module Riser
6
6
  autoload :AcceptTimeout, 'riser/server'
7
+ autoload :CompatibleStringIO, 'riser/compat'
7
8
  autoload :DRbServiceCall, 'riser/services'
8
9
  autoload :DRbServiceServer, 'riser/services'
9
10
  autoload :DRbServices, 'riser/services'
@@ -0,0 +1,28 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require 'stringio'
4
+
5
+ module Riser
6
+ # to use `StringIO' as mock in unit test. this module provides the
7
+ # refinement to add missing `IO' methods to `StringIO'.
8
+ module CompatibleStringIO
9
+ refine StringIO do
10
+ def to_io
11
+ self
12
+ end
13
+
14
+ def to_i
15
+ -1
16
+ end
17
+
18
+ def wait_readable(timeout_seconds)
19
+ ! eof?
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ # Local Variables:
26
+ # mode: Ruby
27
+ # indent-tabs-mode: nil
28
+ # End:
@@ -1,9 +1,12 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  require 'io/wait'
4
+ require 'stringio'
4
5
 
5
6
  module Riser
6
7
  class ReadPoll
8
+ using CompatibleStringIO
9
+
7
10
  def initialize(read_io)
8
11
  @read_io = read_io
9
12
  reset_timer
@@ -215,9 +215,8 @@ module Riser
215
215
  rescue DRb::DRbConnError
216
216
  if (Time.now - t0 >= timeout_seconds) then
217
217
  raise
218
- else
219
- sleep(dt)
220
218
  end
219
+ sleep(dt)
221
220
  retry
222
221
  end
223
222
  end
@@ -1,7 +1,11 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
+ require 'digest'
4
+
3
5
  module Riser
4
6
  class Stream
7
+ using CompatibleStringIO
8
+
5
9
  def initialize(io)
6
10
  @io = io
7
11
  end
@@ -74,36 +78,46 @@ module Riser
74
78
  end
75
79
 
76
80
  class LoggingStream < Stream
81
+ using CompatibleStringIO
82
+
83
+ def self.make_tag(io)
84
+ hex = Digest::SHA256.hexdigest(io.to_s)[0, 7]
85
+ fd = io.to_io.to_i
86
+ "[#{hex},#{fd}]"
87
+ end
88
+
77
89
  def initialize(io, logger)
78
90
  super(io)
79
91
  @logger = logger
92
+ @tag = self.class.make_tag(io)
93
+ @logger.debug("#{@tag} start") if @logger.debug?
80
94
  end
81
95
 
82
96
  def gets
83
97
  line = super
84
- @logger.info("r #{line.inspect}") if @logger.info?
98
+ @logger.info("#{@tag} r #{line.inspect}") if @logger.info?
85
99
  line
86
100
  end
87
101
 
88
102
  def read(size)
89
103
  data = super
90
- @logger.info("r #{data.inspect}") if @logger.info?
104
+ @logger.info("#{@tag} r #{data.inspect}") if @logger.info?
91
105
  data
92
106
  end
93
107
 
94
108
  def readpartial(maxlen, outbuf=nil)
95
109
  data = super
96
- @logger.info("r #{data.inspect}") if @logger.info?
110
+ @logger.info("#{@tag} r #{data.inspect}") if @logger.info?
97
111
  data
98
112
  end
99
113
 
100
114
  def write(message)
101
- @logger.info("w #{message.inspect}") if @logger.info?
115
+ @logger.info("#{@tag} w #{message.inspect}") if @logger.info?
102
116
  super
103
117
  end
104
118
 
105
119
  def close
106
- @logger.info('close') if @logger.info?
120
+ @logger.info("#{@tag} close") if @logger.info?
107
121
  super
108
122
  end
109
123
  end
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Riser
4
- VERSION = '0.1.7'.freeze
4
+ VERSION = '0.1.8'.freeze
5
5
  end
6
6
 
7
7
  # Local Variables:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - TOKI Yoshinori
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-01 00:00:00.000000000 Z
11
+ date: 2019-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,6 +94,7 @@ files:
94
94
  - example/simple_services.rb
95
95
  - example/simple_tls.rb
96
96
  - lib/riser.rb
97
+ - lib/riser/compat.rb
97
98
  - lib/riser/daemon.rb
98
99
  - lib/riser/poll.rb
99
100
  - lib/riser/resource.rb