ZK Service

zk_service is a small library which provides a service registry for Zookeeper.

Servers

This library provides registration to zookeeper through a mixin.

This connection can be set by calling,

For example:

class SomeServer
 include ZkService::Publisher

def intialize
  zk_service_Details( 'localhost', '2181', 'superservice' )
  zk_publish("/some/service/path") #Creates an ephemeral node
  #.....
end

def close
  #.....
  zk_unpublish #explicitly removes the ephemeral node
end

Clients

Upon con requiring a connection to a specific service, a client will consult Zookeeper for the child znodes under '/envname/services/service_name'. These nodes will contain connection details.

For example:

class SuperServiceVendor < ZkService::Vendor

  def initialize(host, port)
    super(host, port)
  end

end

Upon initialization, a child connection can be obtained by:

child_connection = SuperServiceVendorInstance.vend('superservice1')

Connection details can be obtained by:

data = SuperServiceVendorInstance.get_data(child_connection)

Issues

*Need to check for the existence of a Zookeeper ENV and grab the hostname and port number.