def self.select_adapter_class(name=nil)
classes = {
'ffi-rzmq' => SessionAdapter::FfirzmqAdapter,
'cztop' => SessionAdapter::CztopAdapter,
'test' => SessionAdapter::TestAdapter,
}
if (name ||= ENV.fetch('IRUBY_SESSION_ADAPTER', nil))
cls = classes[name]
unless cls.available?
if ENV['IRUBY_SESSION_ADAPTER']
raise SessionAdapterNotFound,
"Session adapter `#{name}` from IRUBY_SESSION_ADAPTER is unavailable"
else
raise SessionAdapterNotFound,
"Session adapter `#{name}` is unavailable"
end
end
if name == 'cztop'
warn "WARNING: cztop is deprecated and will be removed; Use ffi-rzmq instead."
end
return cls
end
classes.each_value do |cls|
return cls if cls.available?
end
raise SessionAdapterNotFound, "No session adapter is available"
end