Class: CZTop::Proxy
Overview
Steerable proxy which switches messages between a frontend and a backend socket.
This is implemented using an Actor.
Defined Under Namespace
Classes: Configurator
Constant Summary collapse
- ZPROXY_FPTR =
function pointer to the zmonitor() function
::CZMQ::FFI.ffi_libraries.each do |dl| fptr = dl.find_function('zproxy') break fptr if fptr end
Instance Attribute Summary collapse
-
#actor ⇒ Actor
readonly
The actor behind this proxy.
Instance Method Summary collapse
-
#backend ⇒ Configurator
Returns a configurator object which you can use to configure the backend socket.
-
#capture(endpoint) ⇒ void
Captures all proxied messages and delivers them to a PULL socket bound to the specified endpoint.
-
#frontend ⇒ Configurator
Returns a configurator object which you can use to configure the frontend socket.
-
#initialize ⇒ Proxy
constructor
A new instance of Proxy.
-
#pause ⇒ void
Pauses proxying of any messages.
-
#resume ⇒ void
Resume proxying of messages.
-
#terminate ⇒ void
Terminates the proxy.
-
#verbose! ⇒ void
Enable verbose logging of commands and activity.
Constructor Details
#initialize ⇒ Proxy
Returns a new instance of Proxy.
21 22 23 |
# File 'lib/cztop/proxy.rb', line 21 def initialize @actor = Actor.new(ZPROXY_FPTR) end |
Instance Attribute Details
#actor ⇒ Actor (readonly)
Returns the actor behind this proxy.
26 27 28 |
# File 'lib/cztop/proxy.rb', line 26 def actor @actor end |
Instance Method Details
#backend ⇒ Configurator
Returns a configurator object which you can use to configure the backend socket.
54 55 56 |
# File 'lib/cztop/proxy.rb', line 54 def backend @backend ||= Configurator.new(self, :backend) end |
#capture(endpoint) ⇒ void
The PULL socket has to be bound before calling this method.
This method returns an undefined value.
Captures all proxied messages and delivers them to a PULL socket bound to the specified endpoint.
64 65 66 67 |
# File 'lib/cztop/proxy.rb', line 64 def capture(endpoint) @actor << ['CAPTURE', endpoint] @actor.wait end |
#frontend ⇒ Configurator
Returns a configurator object which you can use to configure the frontend socket.
46 47 48 |
# File 'lib/cztop/proxy.rb', line 46 def frontend @frontend ||= Configurator.new(self, :frontend) end |
#pause ⇒ void
This causes any messages to be queued up and potentialy hit the high-water mark on the frontend or backend socket, causing messages to be dropped or writing applications to block.
This method returns an undefined value.
Pauses proxying of any messages.
75 76 77 78 |
# File 'lib/cztop/proxy.rb', line 75 def pause @actor << 'PAUSE' @actor.wait end |
#resume ⇒ void
This is only needed after a call to #pause, not to start the proxy. Proxying starts as soon as the frontend and backend sockets are properly attached.
This method returns an undefined value.
Resume proxying of messages.
86 87 88 89 |
# File 'lib/cztop/proxy.rb', line 86 def resume @actor << 'RESUME' @actor.wait end |
#terminate ⇒ void
This method returns an undefined value.
Terminates the proxy.
30 31 32 |
# File 'lib/cztop/proxy.rb', line 30 def terminate @actor.terminate end |
#verbose! ⇒ void
This method returns an undefined value.
Enable verbose logging of commands and activity.
37 38 39 40 |
# File 'lib/cztop/proxy.rb', line 37 def verbose! @actor << 'VERBOSE' @actor.wait end |