lib/ruby_skynet.rb in ruby_skynet-1.2.7 vs lib/ruby_skynet.rb in ruby_skynet-1.3.0.alpha1
- old
+ new
@@ -9,11 +9,42 @@
autoload :Common, 'ruby_skynet/common'
autoload :Connection, 'ruby_skynet/connection'
autoload :Client, 'ruby_skynet/client'
autoload :Service, 'ruby_skynet/service'
autoload :Server, 'ruby_skynet/server'
- autoload :Registry, 'ruby_skynet/registry'
- autoload :ServiceRegistry, 'ruby_skynet/service_registry'
+ autoload :Zookeeper, 'ruby_skynet/zookeeper'
+end
+
+# Autodetect if Zookeeper gem is loaded, otherwise look for Doozer
+module RubySkynet
+ begin
+ require 'zookeeper'
+ require 'zookeeper/client'
+ require 'ruby_skynet/zookeeper/service_registry'
+ # Monkey-patch so that the Zookeeper JRuby code can handle nil values in Zookeeper
+ require 'ruby_skynet/zookeeper/extensions/java_base' if defined?(::JRUBY_VERSION)
+
+ # Shortcuts to loaded Registry classes
+ ServiceRegistry = RubySkynet::Zookeeper::ServiceRegistry
+ CachedRegistry = RubySkynet::Zookeeper::CachedRegistry
+ Registry = RubySkynet::Zookeeper::Registry
+ rescue LoadError
+ begin
+ require 'ruby_doozer'
+ require 'ruby_skynet/doozer/service_registry'
+
+ # Shortcuts to loaded Registry classes
+ ServiceRegistry = RubySkynet::Doozer::ServiceRegistry
+ CachedRegistry = Doozer::CachedRegistry
+ Registry = Doozer::Registry
+ rescue LoadError
+ require 'ruby_skynet/static_service_registry'
+
+ # Use Static Service Registry
+ ServiceRegistry = RubySkynet::StaticServiceRegistry
+ end
+
+ end
end
if defined?(Rails)
require 'ruby_skynet/railtie'
end