PluginBaseClass
# File lib/openshift/runtime/frontend/http/plugins/nodejs-websocket.rb, line 34 def self.purge_by_fqdn(fqdn) NodeJSDBRoutes.open(NodeJSDBRoutes::WRCREAT) do |d| d.delete_if { |k, v| (k == fqdn) or (v["alias"] == fqdn) } d.delete_if { |k, v| k.split('/')[0] == fqdn } end end
# File lib/openshift/runtime/frontend/http/plugins/nodejs-websocket.rb, line 150 def add_alias(name) NodeJSDBRoutes.open(NodeJSDBRoutes::WRCREAT) do |d| begin routes_ent = d.fetch(@fqdn) if not routes_ent.nil? alias_ent = routes_ent.clone alias_ent["alias"] = @fqdn d.store(name, alias_ent) end rescue KeyError end end end
# File lib/openshift/runtime/frontend/http/plugins/nodejs-websocket.rb, line 144 def aliases NodeJSDBRoutes.open(NodeJSDBRoutes::READER) do |d| return d.select { |k, v| v["alias"] == @fqdn }.map { |k, v| k } end end
# File lib/openshift/runtime/frontend/http/plugins/nodejs-websocket.rb, line 45 def connect(*elements) reported_urls = [] NodeJSDBRoutes.open(NodeJSDBRoutes::WRCREAT) do |d| elements.each do |path, uri, options| # Check if the path supports websockets next unless options["websocket"] # Check if the endpoints support websockets # next if options["protocols"] and ["ws"].select { |proto| options["protocols"].include?(proto) }.empty? conn = options["connections"] if conn.nil? conn = 5 end bw = options["bandwidth"] if bw.nil? bw = 100 end # Use the websocket port if it is passed as an option port = options["websocket_port"] if port uri = uri.sub(/:(\d)+/, ":" + port.to_s) end routes_ent = { "endpoints" => [ uri ], "limits" => { "connections" => conn, "bandwidth" => bw } } d.store(@fqdn + path, routes_ent) d.select { |k, v| v["alias"] == @fqdn }.each do |k, v| v.merge!(routes_ent) end end end reported_urls end
# File lib/openshift/runtime/frontend/http/plugins/nodejs-websocket.rb, line 90 def connections begin NodeJSDBRoutes.open(NodeJSDBRoutes::READER) do |d| routes_ent = d.fetch(@fqdn) if routes_ent path="" uri = routes_ent["endpoints"].first options={} options.merge!(routes_ent["limits"]) options["websocket"]=1 options["protocols"]=[ "ws" ] return [ [ path, uri, options ] ] end end rescue end [ ] end
# File lib/openshift/runtime/frontend/http/plugins/nodejs-websocket.rb, line 41 def destroy self.class.purge_by_fqdn(@fqdn) end
# File lib/openshift/runtime/frontend/http/plugins/nodejs-websocket.rb, line 110 def disconnect(*paths) NodeJSDBRoutes.open(NodeJSDBRoutes::WRCREAT) do |d| paths.flatten.each do |p| d.delete(@fqdn + p) end end end
# File lib/openshift/runtime/frontend/http/plugins/nodejs-websocket.rb, line 119 def idle NodeJSDBRoutes.open(NodeJSDBRoutes::WRCREAT) do |d| d.select { |k, v| ( k == @fqdn ) or (v["alias"] == @fqdn ) }.each do |k, entry| entry["idle"]=@container_uuid end end end
# File lib/openshift/runtime/frontend/http/plugins/nodejs-websocket.rb, line 135 def idle? NodeJSDBRoutes.open(NodeJSDBRoutes::READER) do |d| if d[@fqdn] return d[@fqdn]["idle"] end end nil end
Generated with the Darkfish Rdoc Generator 2.