lib/asynchronic.rb in asynchronic-0.0.1 vs lib/asynchronic.rb in asynchronic-0.1.0
- old
+ new
@@ -1,48 +1,33 @@
-require 'ost'
+require 'forwardable'
require 'securerandom'
-require 'base64'
+require 'redis'
+require 'ost'
+require 'class_config'
require 'logger'
-require 'fileutils'
-Dir.glob(File.expand_path('asynchronic/*.rb', File.dirname(__FILE__))).sort.each { |f| require f }
+Dir.glob(File.expand_path('asynchronic/**/*.rb', File.dirname(__FILE__))).sort.each { |f| require f }
module Asynchronic
- def self.default_queue
- @default_queue ||= :asynchronic
- end
+ UUID_REGEXP = '[a-z\d]{8}-[a-z\d]{4}-[a-z\d]{4}-[a-z\d]{4}-[a-z\d]{12}'
- def self.default_queue=(name)
- @default_queue = name
- end
+ extend ClassConfig
- def self.logger
- @logger ||= Logger.new($stdout)
- end
+ attr_config :default_queue, :asynchronic
+ attr_config :queue_engine, QueueEngine::InMemory.new
+ attr_config :data_store, DataStore::InMemory.new
+ attr_config :logger, Logger.new($stdout)
- def self.logger=(logger)
- @logger = logger
+ def self.environment
+ Environment.new queue_engine, data_store
end
- def self.connect_redis(options)
- Ost.connect options
- @redis = Redis.new options
+ def self.[](pid)
+ environment.load_process pid
end
- def self.redis
- @redis ||= Redis.current
- end
-
- def self.archiving_path
- @archiving_path ||= File.join(Dir.home, '.asynchronic', 'data')
- end
-
- def self.archiving_path=(path)
- @archiving_path = path
- end
-
- def self.archiving_file(name)
- File.join archiving_path, "#{name}.bin"
+ def self.processes
+ environment.processes
end
end
\ No newline at end of file