lib/cleo/cleo.rb in acts_as_cleo-3.0.0 vs lib/cleo/cleo.rb in acts_as_cleo-3.0.1
- old
+ new
@@ -1,16 +1,24 @@
#Load Cleo Sub Modules
+
require File.dirname(__FILE__) + '/base_server'
require File.dirname(__FILE__) + '/connection_server'
require File.dirname(__FILE__) + '/element_server'
require File.dirname(__FILE__) + '/service'
+require File.dirname(__FILE__) + '/element'
+require 'resque'
+
+
module Cleo
def self.query(query)
Cleo::ElementServer.query(query)
end
+ def self.network_query(source_id, query)
+ end
+
def self.net_http
uri = URI.parse(Cleo::Service.url)
Net::HTTP.new(uri.host, uri.port)
end
@@ -19,12 +27,24 @@
return response if Cleo::Service.good_response_code?(response)
end
def self.flush
- uri = URI.parse Cleo::Service.url + "elements/flush"
+ Cleo.flush_elements and Cleo.flush_connections
+ end
+
+ def self.flush_connections
+ uri = URI.parse Cleo::Service.connection_server_url + "flush"
request = Net::HTTP::Post.new(uri.path)
- Net::HTTP.new(uri.host, uri.port).start { |http| http.request request }
+ response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request request }
+ Cleo::Service.good_response_code?(response)
+ end
+
+ def self.flush_elements
+ uri = URI.parse Cleo::Service.element_server_url + "flush"
+ request = Net::HTTP::Post.new(uri.path)
+ response = Net::HTTP.new(uri.host, uri.port).start { |http| http.request request }
+ Cleo::Service.good_response_code?(response)
end
def self.configure(new_config)
parts = new_config[:url].split("/")
parts -= %w{rest elements connections}