Adding release checksum.
Signing v1.0.0
Added tag v1.0.0 for changeset 2907774f4131
home : https://hg.sr.ht/~ged/CZTop-Reactor
code : https://hg.sr.ht/~ged/CZTop-Reactor/browse
github : https://github.com/ged/cztop-reactor
docs : http://deveiate.org/code/cztop-reactor
This is an implementation of the Reactor pattern described in Pattern-Oriented Software Architecture (Volume 2). It allows an asynchronous application to be described as one or more "reactions" to events, in this case either I/O conditions on a ZMQ socket or a timer expiring.
A simple example:
# Start a SERVER socket, and print out any messages sent to it
reactor = CZTop::Reactor.new
socket = CZTop::Socket::SERVER.new
socket.bind( 'tcp://0.0.0.0:8' )
reactor.register( socket, :read ) do |event|
if event.readable?
message = event.socket.receive
puts "Read: %p" % [ message.to_a ]
end
end
reactor.start_polling
It should run under any Ruby interpreter that CZTop will, which at the time of this writing includes:
I am also using it (and CZTop) under MRI 2.6.
$ gem install cztop-reactor
I considered submitting this as a patch to cztop
, but in the end elected to
distribute it as a gem for two reasons:
timers
gem, and I didn't want to add this dependency to
cztop
. If the ztimerset
spec ever comes out of draft status
and cztop
adds an implementation of it, this wouldn't be necessary.You can check out the current development source with Mercurial via its {project page}[https://hg.sr.ht/~ged/CZTop-Reactor]. Or if you prefer Git, via {its Github mirror}[https://github.com/ged/cztop-reactor].
After checking out the source, run:
$ rake newb
This task will install any missing dependencies, run the tests/specs, and generate the API documentation.
This library includes source from the CZTop gem by Patrik Wenger, which is distributed under the terms of the ISC License:
Copyright (c) 2016, Patrik Wenger
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Everything else is distributed under the same license but is:
Copyright (c) 2017-2022, Michael Granger