Sha256: 51586cf4033f603d43aa1c12d4c3f58675ad078a69017d49342e00acd99c7f2c

Contents?: true

Size: 777 Bytes

Versions: 2

Compression:

Stored size: 777 Bytes

Contents

# encoding: utf-8

require 'zoomq/jeromq-0.3.0-20130721.175323-20.jar'
java_import org.zeromq.ZMQ

require 'forwardable'

require 'zoomq/zookeeper'
require 'zoomq/server/worker'

module ZooMQ
  class Server

    extend Forwardable
    def_delegators :@zk, :globals, :locals, :announce
    def_delegators :@ctx, :create_socket

    attr_reader :log, :fqdn, :port

    def initialize(service_name, zookeeper_uri, log)
      Signal.register_shutdown_handler { shutdown }
      @log = log
      @zk = Zookeeper.new("#{zookeeper_uri}/#{service_name}")
      @ctx = ZContext.new
      @fqdn = Socket.gethostbyname(Socket.gethostname).first
    end

    def run
      Worker.new(self).run
    end

    def shutdown
      @ctx.destroy if @ctx
      @zk.close if @zk
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
zoomq-0.1.1 lib/zoomq/server.rb
zoomq-0.1.0 lib/zoomq/server.rb