Class: LanGrove::Behaviour::Enqueueable

Inherits:
LanGrove::Base show all
Defined in:
lib/langrove/behaviour/enqueueable.rb

Instance Attribute Summary

Attributes inherited from LanGrove::Base

#logger

Instance Method Summary collapse

Methods inherited from LanGrove::Base

#config_exception, #type

Constructor Details

#initialize(root, config, name) ⇒ Enqueueable

Returns a new instance of Enqueueable.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/langrove/behaviour/enqueueable.rb', line 9

def initialize( root, config, name )
  
  @requires = {
    
    #
    # Enqueueable requires a Enqueuer plugin.
    #
    :enqueuer => {
      
      :actions => [
        
        #
        # Plugin should implement:
        # 
        # <Plugin>.enqueue_key( handler )
        # 
        # - Should enqueue a job with the handler.key
        #   as parameter.
        # 
        # 
        #   This will allow for a worker daemon to 
        #   process the queue for key's and then
        #   collect from persistance the data to be 
        #   processed.
        # 
        #   eg. A monitoring system may defer :escalate_if 
        #       jobs to an escalator daemon. This worker
        #       would likely want to evaluate the latest 
        #       current state, despite any potential queue 
        #       backlog.
        #  
        #       Deferring the key only and having the Worker
        #       collect the capsule from persistance will 
        #       create the posibility of:
        # 
        #       - Always processing the latest state.
        # 
        #       - Never late-processing a state that
        #         has subsequently been updated and is
        #         now irrelevant.
        # 
        # 
        #  Caveats (currently unmitigated)
        # 
        #  - Fire and Forget document stores, e.g MongoDB
        #    may lead to a situation where the job to process
        #    ocurrs ahead of the actual storage completing.
        # 
        # 
        # 
        # - Success assumed.
        # - (on failure) Should THROW
        #
        :enqueue_key,
        
        #
        # Plugin should implement:
        #
        # <Plugin>.enqueue_capsule( handler )
        #
        # - Should defer a job with the ENTIRE handler.capsule 
        #   DUPLICATED into the job parameter.
        #
        # 
        # 
        # eg. A monitoring system may defer :build_archive
        #     jobs to a team of worker daemons assembling
        #     state history.
        # 
        #     These worker daemons would typically want 
        #     the entire state as at the moment being 
        #     archived.
        #
        # 
        # - Success assumed.
        # - (on failure) Should THROW
        # 
        :enqueue_capsule
        
      ],
      
      :version => ENQUEUEABLE_VERSION
      
    }
    
  } if @requires.nil?
  
  super
  
end