Sha256: ed16c14c048767814f34880cc91853f392788e0735174e180fa456baa7e6dc7c
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
require 'miu/sockets' require 'miu/proxy' require 'ffi-rzmq' module Miu class Forwarder def initialize(options = {}) @pub = pub_socket_class.new @pub.bind Miu::Socket.build_address(options[:pub_host], options[:pub_port]) @sub = sub_socket_class.new @sub.bind Miu::Socket.build_address(options[:sub_host], options[:sub_port]) @sub.subscribe '' if options[:bridge_port] @bridge = sub_socket_class.new @bridge.connect Miu::Socket.build_address(options[:bridge_host], options[:bridge_port]) @bridge.subscribe '' end end def close @bridge.close if @bridge @sub.close @pub.close end def run frontends = [@sub, @bridge].compact backends = [@pub] proxy = Proxy.new frontends, backends proxy.run end private def pub_socket_class if ::ZMQ::LibZMQ.version3? XPubSocket else PubSocket end end def sub_socket_class if ::ZMQ::LibZMQ.version3? XSubSocket else SubSocket end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
miu-0.2.3 | lib/miu/forwarder.rb |
miu-0.2.2 | lib/miu/forwarder.rb |
miu-0.2.1 | lib/miu/forwarder.rb |