This library spawns a child process which communicates with the DDSL command line tool.
Just a proof of concept.
gem install ddslbg
Note that this gem spawns a Java process running a standalone jar, so a working JRE is required.
Please see the main DDSL documentation for concepts and details.
require 'ddslbg'
$ddsl = Ddslbg::Client.new
$ddsl.zookeeper_hosts = ['localhost:2181', 'some.other.server.com:2181']
$ddsl.available_services
service = {
id: {environment: 'test', serviceType: 'http', name: 'cmd-tool', version: '0.1'},
sl: {url: 'http://localhost:4321/hi', quality: 1.0, lastUpdated: 1347398923243, ip: '127.0.0.1'}
}
$ddsl.up(service)
$ddsl.down(service)
service_request = {
'sid' => {'environment' => 'test', 'serviceType' => 'telnet', 'name' => 'telnetServer', 'version' => '0.1'},
'cid' => {'environment' => 'Client env', 'name' => 'client name', 'version' => 'version', 'ip' => 'ip-address'}
}
$ddsl.best_service_location(service_request)
$ddsl.service_locations(service_request)
fallbacks = {
'ServiceId(test,telnet,telnetServer,0.1)' => 'http://example.com/foo',
'ServiceId(test,http,BarServer,1.0)' => 'http://example.com/bar'
}
$ddsl.fallback_urls = fallbacks
Use $ddsl.disconnect!
to kill off the spawned process.