Class: Flor::Trap
Instance Method Summary collapse
-
#fei ⇒ Object
create_table :flor_traps do.
- #to_hook ⇒ Object
- #trigger(executor, message) ⇒ Object
- #within_itself?(executor, message) ⇒ Boolean
Methods inherited from FlorModel
#data, #execution, from_h, #node, #payload, #refresh, #storage, #to_h, #unit
Instance Method Details
#fei ⇒ Object
create_table :flor_traps do
primary_key :id, type: :Integer
String :domain, null: false
String :exid, null: false
String :onid, null: false
String :nid, null: false
#
TrueClass :tconsumed, null: false, default: false
String :trange, null: false
String :tpoints, null: true
String :ttags, null: true
String :theats, null: true
String :theaps, null: true
#
File :content # JSON msg to trigger
#
String :status, null: false
String :ctime, null: false
String :mtime, null: false
String :cunit
String :munit
String :bnid, null: false
index :exid
index [ :exid, :nid ]
end
37 |
# File 'lib/flor/unit/models/trap.rb', line 37 def fei; [ exid, nid ].join('-') rescue nil; end |
#to_hook ⇒ Object
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 |
# File 'lib/flor/unit/models/trap.rb', line 39 def to_hook opts = {} opts[:consumed] = tconsumed opts[:point] = tpoints.split(',') if tpoints opts[:tag] = do_split() if opts[:heap] = do_split(theaps) if theaps opts[:heat] = do_split(theats) if theats opts[:name] = data['names'] case trange when 'execution' opts[:exid] = exid when 'subdomain' opts[:subdomain] = Flor.domain(exid) when 'domain' opts[:domain] = Flor.domain(exid) else #'subnid' # default opts[:exid] = exid opts[:subnid] = true end [ "trap#{id}", opts, self, nil ] end |
#trigger(executor, message) ⇒ Object
67 68 69 70 |
# File 'lib/flor/unit/models/trap.rb', line 67 def trigger(executor, ) [ decrement, [ (executor, ) ] ] end |
#within_itself?(executor, message) ⇒ Boolean
72 73 74 75 76 77 78 79 80 |
# File 'lib/flor/unit/models/trap.rb', line 72 def within_itself?(executor, ) return false if ['exid'] != exid n = executor.node(['from'] || ['nid'], true) return false if n == nil n.descendant_of?(onid) end |