Class: ZMQ::Proxy

Inherits:
Object
  • Object
show all
Defined in:
lib/0mq/proxy.rb

Overview

The proxy connects a frontend socket to a backend socket. Conceptually, data flows from frontend to backend. Depending on the socket types, replies may flow in the opposite direction. The direction is conceptual only; the proxy is fully symmetric and there is no technical difference between frontend and backend.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(frontend, backend, capture = nil) ⇒ Proxy

Accepts a frontend, backend, and optional capture socket. See api.zeromq.org/4-0:zmq-proxy



18
19
20
21
22
# File 'lib/0mq/proxy.rb', line 18

def initialize(frontend, backend, capture = nil)
  @frontend = frontend.nil? ? nil : frontend.to_ptr
  @backend  = backend.nil?  ? nil : backend.to_ptr
  @capture  = capture.nil?  ? nil : capture.to_ptr
end

Class Method Details

.proxy(frontend, backend, capture = nil) ⇒ Object

Create a running proxy object.



12
13
14
# File 'lib/0mq/proxy.rb', line 12

def self.proxy(frontend, backend, capture = nil)
  new(frontend, backend, capture).tap { |p| p.run }
end

Instance Method Details

#runObject

Block the current thread with the event loop of the proxy



25
26
27
# File 'lib/0mq/proxy.rb', line 25

def run
  LibZMQ.zmq_proxy @frontend, @backend, @capture
end