Class: Ruote::CompositeStorage

Inherits:
Object
  • Object
show all
Includes:
StorageBase
Defined in:
lib/ruote/storage/composite_storage.rb

Overview

This storage allows for mixing of storage implementation or simply mixing of storage physical backend.

opts = {}

engine =
  Ruote::Engine.new(
    Ruote::Worker.new(
      Ruote::CompositeStorage.new(
        Ruote::FsStorage.new('ruote_work', opts),
        'msgs' => Ruote::HashStorage.new(opts))))

In this example, everything goes to the FsStorage, except the messages (msgs) that go to an in-memory storage.

Constant Summary

Instance Method Summary (collapse)

Methods included from StorageBase

#clear, #context, #context=, #copy_to, #delete_schedule, #empty?, #expression_wfids, #find_root_expression, #get_configuration, #get_engine_variable, #get_msgs, #get_schedules, #get_trackers, #put_engine_variable, #put_msg, #put_schedule, #reserve

Constructor Details

- (CompositeStorage) initialize(default_storage, storages)

A new instance of CompositeStorage



50
51
52
53
54
55
56
# File 'lib/ruote/storage/composite_storage.rb', line 50

def initialize(default_storage, storages)

  @default_storage = default_storage
  @storages = storages

  prepare_base_methods
end

Instance Method Details

- (Object) delete(doc)



68
69
70
71
# File 'lib/ruote/storage/composite_storage.rb', line 68

def delete(doc)

  storage(doc['type']).delete(doc)
end

- (Object) get(type, key)



63
64
65
66
# File 'lib/ruote/storage/composite_storage.rb', line 63

def get(type, key)

  storage(type).get(type, key)
end

- (Object) get_many(type, key = nil, opts = {})



73
74
75
76
# File 'lib/ruote/storage/composite_storage.rb', line 73

def get_many(type, key=nil, opts={})

  storage(type).get_many(type, key, opts)
end

- (Object) ids(type)



78
79
80
81
# File 'lib/ruote/storage/composite_storage.rb', line 78

def ids(type)

  storage(type).ids(type)
end

- (Object) purge!



83
84
85
86
# File 'lib/ruote/storage/composite_storage.rb', line 83

def purge!

  TYPES.collect { |t| storage(t) }.uniq.each { |s| s.purge! }
end

- (Object) purge_type!(type)



88
89
90
91
# File 'lib/ruote/storage/composite_storage.rb', line 88

def purge_type!(type)

  storage(type).purge_type!(type)
end

- (Object) put(doc, opts = {})



58
59
60
61
# File 'lib/ruote/storage/composite_storage.rb', line 58

def put(doc, opts={})

  storage(doc['type']).put(doc, opts)
end