Module: Bramble

Defined in:
lib/bramble.rb,
lib/bramble/map.rb,
lib/bramble/conf.rb,
lib/bramble/keys.rb,
lib/bramble/state.rb,
lib/bramble/reduce.rb,
lib/bramble/result.rb,
lib/bramble/map_job.rb,
lib/bramble/storage.rb,
lib/bramble/version.rb,
lib/bramble/base_job.rb,
lib/bramble/begin_job.rb,
lib/bramble/serialize.rb,
lib/bramble/reduce_job.rb,
lib/bramble/storage/redis_storage.rb,
lib/bramble/storage/memory_storage.rb

Defined Under Namespace

Modules: Keys, Map, Reduce, Serialize, State, Storage Classes: BaseJob, BeginJob, MapJob, ReduceJob, Result

Constant Summary collapse

CONF =
OpenStruct.new(
  redis_conn: nil,
  namespace: "Bramble",
  queue_as: :bramble,
  storage: Bramble::Storage::RedisStorage
)
VERSION =
"0.4.0"

Class Method Summary collapse

Class Method Details

.configObject



18
19
20
21
22
23
24
# File 'lib/bramble.rb', line 18

def self.config
  if block_given?
    yield(Bramble::CONF)
  else
    Bramble::CONF
  end
end

.delete(handle) ⇒ Object

Remove results for ‘handle`, if there are any



47
48
49
# File 'lib/bramble.rb', line 47

def self.delete(handle)
  Bramble::State.clear_job(handle)
end

.get(handle) ⇒ Bramble::Result



42
43
44
# File 'lib/bramble.rb', line 42

def self.get(handle)
  Bramble::Result.new(handle)
end

.map_reduce(handle, implementation, items_options = {}) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bramble.rb', line 29

def self.map_reduce(handle, implementation, items_options = {})
  # Secret feature: the implementation can provide a job_id
  job_id = if implementation.respond_to?(:job_id)
    implementation.job_id
  else
    Time.now.strftime("%s%6N")
  end
  handle = "#{handle}:#{job_id}"
  Bramble::State.start_job(handle)
  Bramble::BeginJob.perform_later(handle, implementation.name, items_options)
end