cztop-reactor 0.5.0 → 0.6.0

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: 17bf40bedf4749f22ba30e33ea82296f2936267c4fcefc3c01d2e795ad7d741c
4
- data.tar.gz: 00063eb4d49d06906fa50e778447816503302b42e8551cc6cb3ccae7b7422e70
3
+ metadata.gz: c35b32fd4ad494b65ff397c7bc78e0c2f02cffbd9745bc674c6813de209844b1
4
+ data.tar.gz: a13ddcdbbf60a25b2e06675fb00430502cb1d5808ad65c01c7de531856ed0669
5
5
  SHA512:
6
- metadata.gz: fdab82704df0e87ac9b742fff14d72dc3c9d0b48d7d9fc5af76160a662ff8fa3b4ec5d3567246ba4c9ea7b0e8c56cf0fde171d2542d8a91f539774f12eb21500
7
- data.tar.gz: 202f8a04ccb8bc02653eca063777b1c949fdb6bfe27561c94ed2205af5b4fea1b6d28e27948092ad24eff8c09af4ab143ae8264ba09626b2719eb42de9732538
6
+ metadata.gz: 356fde892a03e56418ceada7be45cf08e1cb1355f67e6c3ad7cb7aed4cc408dfd029598d81473715c3eaf1c4ab809eed3966d2b1c8bfca3f8ba6c770ea0da151
7
+ data.tar.gz: 26a7370a6a141b4e0959bbead2b51c9bfa72711c1f5a369bacc61eb7aabb7c9fcea6ee8a4f20341625863d0ba4b370ee70417e5875ea70ec7130bb82810f15cb
Binary file
data.tar.gz.sig CHANGED
Binary file
data/ChangeLog CHANGED
@@ -1,8 +1,81 @@
1
+ 2018-07-21 Michael Granger <ged@FaerieMUD.org>
2
+
3
+ * Manifest.txt, lib/cztop/reactor/socket_monitoring.rb,
4
+ spec/cztop/reactor/socket_monitoring_spec.rb:
5
+ Add a socket monitor mixin
6
+ [e65cdcbe5f89] [tip]
7
+
8
+ 2018-07-11 Michael Granger <ged@FaerieMUD.org>
9
+
10
+ * .hgtags:
11
+ Added tag v0.5.0 for changeset c82d889b3d2e
12
+ [0338a8ab0f8b]
13
+
14
+ * .hgsigs:
15
+ Added signature for changeset c6276b15f479
16
+ [c82d889b3d2e] [v0.5.0]
17
+
18
+ * History.md, Rakefile, cztop-reactor.gemspec, lib/cztop/reactor.rb:
19
+ Bump the minor version, cztop dep, and update History.
20
+ [c6276b15f479]
21
+
22
+ * cztop-reactor.gemspec, lib/cztop/reactor.rb,
23
+ spec/cztop/reactor_spec.rb:
24
+ Added methods to pause/resume all timers.
25
+ [67cfabefffd2]
26
+
27
+ 2018-06-27 Michael Granger <ged@FaerieMUD.org>
28
+
29
+ * .hgtags:
30
+ Added tag v0.4.0 for changeset 36b814356934
31
+ [9e371cd81152]
32
+
33
+ * .hgsigs:
34
+ Added signature for changeset 4fa4ea9f2a91
35
+ [36b814356934] [v0.4.0]
36
+
37
+ * History.md, lib/cztop/reactor.rb:
38
+ Bump the minor version, update history.
39
+ [4fa4ea9f2a91]
40
+
41
+ * .ruby-version, lib/cztop/reactor.rb:
42
+ Make the reactor threadsafe
43
+ [c0beb742a2a2]
44
+
45
+ 2018-06-06 Michael Granger <ged@FaerieMUD.org>
46
+
47
+ * Merged with 33bf1ec41017
48
+ [9ca502f040d3]
49
+
50
+ * lib/cztop/reactor/signal_handling.rb:
51
+ Fix docs and logging in signal handling mixin
52
+ [0adc6861a172]
53
+
54
+ * lib/cztop/reactor.rb:
55
+ Guard against events with no sockets
56
+ [749f5de1d5fe]
57
+
58
+ * certs/ged.pem:
59
+ Update my gem-signing cert
60
+ [26089589e937]
61
+
62
+ 2017-11-07 Michael Granger <ged@FaerieMUD.org>
63
+
64
+ * .ruby-version:
65
+ Update to Ruby 2.4
66
+ [33bf1ec41017]
67
+
68
+ 2017-05-19 Michael Granger <ged@FaerieMUD.org>
69
+
70
+ * Rakefile, cztop-reactor.gemspec:
71
+ Fix the rules for the gemspec.
72
+ [469956f9635b]
73
+
1
74
  2017-05-16 Michael Granger <ged@FaerieMUD.org>
2
75
 
3
76
  * .hgtags:
4
77
  Added tag v0.3.0 for changeset 93726ed1d11c
5
- [4a5ff1ab5370] [tip]
78
+ [4a5ff1ab5370]
6
79
 
7
80
  * .hgsigs:
8
81
  Added signature for changeset b27d8748d922
@@ -67,7 +140,7 @@
67
140
 
68
141
  * .hgsigs:
69
142
  Added signature for changeset 8616ee222428
70
- [10a0b983e907] [github/master]
143
+ [10a0b983e907]
71
144
 
72
145
  * .hgtags:
73
146
  Added tag v0.1.0.pre20170323172345 for changeset 77db55f567df
data/History.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## v0.6.0 [2018-07-21] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Enhancements:
4
+
5
+ - Add a mixin for easy socket monitoring setup.
6
+
7
+
1
8
  ## v0.5.0 [2018-07-11] Michael Granger <ged@FaerieMUD.org>
2
9
 
3
10
  Enhancements:
@@ -10,7 +10,9 @@ Rakefile
10
10
  lib/cztop/reactor.rb
11
11
  lib/cztop/reactor/event.rb
12
12
  lib/cztop/reactor/signal_handling.rb
13
+ lib/cztop/reactor/socket_monitoring.rb
13
14
  spec/cztop/reactor/event_spec.rb
14
15
  spec/cztop/reactor/signal_handling_spec.rb
16
+ spec/cztop/reactor/socket_monitoring_spec.rb
15
17
  spec/cztop/reactor_spec.rb
16
18
  spec/spec_helper.rb
@@ -24,7 +24,7 @@ class CZTop::Reactor
24
24
  include MonitorMixin
25
25
 
26
26
  # The version of this library
27
- VERSION = '0.5.0'
27
+ VERSION = '0.6.0'
28
28
 
29
29
  # The maximum number of seconds to wait for events when there are no timers
30
30
  # registered.
@@ -0,0 +1,117 @@
1
+ # -*- ruby -*-
2
+ # frozen_string_literal: true
3
+
4
+ require 'cztop/reactor' unless defined?( CZTop::Reactor )
5
+
6
+ # Methods for logging monitor events.
7
+ module CZTop::Reactor::SocketMonitoring
8
+
9
+ ### Inclusion callback -- add Loggability to including classes.
10
+ def self::included( mod )
11
+ super
12
+ mod.extend( Loggability )
13
+ mod.log_to( :cztop ) unless Loggability.log_host?( mod )
14
+ end
15
+
16
+
17
+ ### Set up a monitor instance variable on object creation.
18
+ def initialize( * ) # :notnew:
19
+ @monitor = nil
20
+ end
21
+
22
+ ##
23
+ # The CZTop::Monitor for the server socket
24
+ attr_reader :monitor
25
+
26
+
27
+ ### Run the block with monitoring for the specified +socket+.
28
+ def with_socket_monitor( reactor, socket, *events )
29
+ mon = self.set_up_socket_monitor( reactor, socket )
30
+
31
+ return yield
32
+ ensure
33
+ self.clean_up_socket_monitor( mon )
34
+ end
35
+
36
+
37
+ ### Create a monitor for the specified +socket+.
38
+ def set_up_socket_monitor( reactor, socket, *events )
39
+ return reactor.register_monitor( socket, *events, &self.method(:on_monitor_event) )
40
+ end
41
+
42
+
43
+ ### Tear down the monitor.
44
+ def clean_up_socket_monitor( mon )
45
+ mon.terminate if mon
46
+ end
47
+
48
+
49
+ ### Handle monitor events.
50
+ def on_monitor_event( monitor_event )
51
+ self.log.debug "Got monitor event: %p" % [ monitor_event ]
52
+
53
+ msg = monitor_event.socket.receive
54
+ type, *payload = *msg
55
+ callback_name = "on_#{type.downcase}"
56
+
57
+ if self.respond_to?( callback_name, true )
58
+ self.send( callback_name, *payload )
59
+ else
60
+ self.log.warn "No handler (#%s) for monitored %s event." % [ callback_name, type ]
61
+ end
62
+ end
63
+ alias_method :handle_monitor_event, :on_monitor_event
64
+
65
+
66
+ #########
67
+ protected
68
+ #########
69
+
70
+ ### Monitor event callback for socket connection events
71
+ def on_connected( fd, endpoint )
72
+ self.log.debug "Client socket on FD %d connected" % [ fd ]
73
+ end
74
+
75
+
76
+ ### Monitor event callback for socket accepted events
77
+ def on_accepted( fd, endpoint )
78
+ self.log.debug "Client socket on FD %d accepted" % [ fd ]
79
+ end
80
+
81
+
82
+ ### Monitor event callback for successful auth events.
83
+ def on_handshake_succeeded( fd, endpoint )
84
+ self.log.debug "Client socket on FD %d handshake succeeded" % [ fd ]
85
+ end
86
+
87
+
88
+ ### Monitor event callback for failed auth events.
89
+ def on_handshake_failed( fd, endpoint )
90
+ self.log.debug "Client socket on FD %d handshake failed" % [ fd ]
91
+ end
92
+
93
+
94
+ ### Monitor event callback for failed handshake events.
95
+ def on_handshake_failed_no_detail( fd, endpoint )
96
+ self.log.debug "Client socket on FD %d handshake failed; no further details are known" % [ fd ]
97
+ end
98
+
99
+
100
+ ### Monitor event callback for failed handshake events.
101
+ def on_handshake_failed_protocol( fd, endpoint )
102
+ self.log.debug "Client socket on FD %d handshake failed: protocol error" % [ fd ]
103
+ end
104
+
105
+
106
+ ### Monitor event callback for socket closed events
107
+ def on_closed( fd, endpoint )
108
+ self.log.debug "Client socket on FD %d closed" % [ fd ]
109
+ end
110
+
111
+
112
+ ### Monitor event callback for socket disconnection events
113
+ def on_disconnected( fd, endpoint )
114
+ self.log.debug "Client socket on FD %d disconnected" % [ fd ]
115
+ end
116
+
117
+ end # module CZTop::Reactor::SocketMonitoring
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env rspec -cfd
2
+
3
+ require_relative '../../spec_helper'
4
+
5
+ require 'cztop/reactor/socket_monitoring'
6
+
7
+
8
+ describe CZTop::Reactor::SocketMonitoring do
9
+
10
+ it "can add a socket monitor setup to a reactor for a block" do
11
+ including_class = Class.new do
12
+
13
+ def initialize
14
+ @monitor_events = []
15
+ end
16
+
17
+ attr_reader :monitor_events
18
+
19
+ def on_connect_delayed( fd, endpoint )
20
+ @monitor_events << :connect_delayed
21
+ end
22
+
23
+ end
24
+
25
+ including_class.include( described_class )
26
+
27
+ obj = including_class.new
28
+ reactor = CZTop::Reactor.new
29
+ listener = CZTop::Socket::SERVER.new( '@tcp://127.0.0.1:*' )
30
+ socket = CZTop::Socket::CLIENT.new
31
+
32
+ obj.with_socket_monitor( reactor, socket, :CONNECTED ) do
33
+ socket.connect( listener.last_endpoint )
34
+ reactor.poll_once
35
+ end
36
+
37
+ expect( obj.monitor_events ).to include( :connect_delayed )
38
+ end
39
+
40
+
41
+ end
42
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cztop-reactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -35,7 +35,7 @@ cert_chain:
35
35
  X0qdrKi+2aZZ0NGuFj9AItBsVmAvkBGIpX4TEKQp5haEbPpmaqO5nIIhV26PXmyT
36
36
  OMKv6pWsoS81vw5KAGBmfX8nht/Py90DQrbRvakATGI=
37
37
  -----END CERTIFICATE-----
38
- date: 2018-07-11 00:00:00.000000000 Z
38
+ date: 2018-07-23 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: loggability
@@ -218,8 +218,10 @@ files:
218
218
  - lib/cztop/reactor.rb
219
219
  - lib/cztop/reactor/event.rb
220
220
  - lib/cztop/reactor/signal_handling.rb
221
+ - lib/cztop/reactor/socket_monitoring.rb
221
222
  - spec/cztop/reactor/event_spec.rb
222
223
  - spec/cztop/reactor/signal_handling_spec.rb
224
+ - spec/cztop/reactor/socket_monitoring_spec.rb
223
225
  - spec/cztop/reactor_spec.rb
224
226
  - spec/spec_helper.rb
225
227
  homepage: http://deveiate.org/projects/cztop-reactor
@@ -244,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
246
  version: '0'
245
247
  requirements: []
246
248
  rubyforge_project:
247
- rubygems_version: 2.7.6
249
+ rubygems_version: 2.7.7
248
250
  signing_key:
249
251
  specification_version: 4
250
252
  summary: This is an implementation of the Reactor pattern described in [Pattern-Oriented
metadata.gz.sig CHANGED
Binary file