Class: Goat::UpdateDispatcher
Class Method Summary collapse
- .component_updated(pgid, update) ⇒ Object
- .dispatch_update(update) ⇒ Object
- .dispatch_updates(txn, pgid, ups) ⇒ Object
- .enable ⇒ Object
- .finish_txn(txn_id) ⇒ Object
- .txn_complete(n) ⇒ Object
- .txn_start(n) ⇒ Object
Class Method Details
.component_updated(pgid, update) ⇒ Object
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 |
# File 'lib/goat.rb', line 1102 def self.component_updated(pgid, update) if Dynamic.variable?(:txn) txn = Dynamic[:txn] txn_pgid = Dynamic[:txn_pgid] if updates = @active_txns[txn] if pgid == txn_pgid updates[:page_updates] << update else updates[:other_updates] << update end else raise "Got an update for an un-started txn (#{txn.inspect}, #{pgid})" end else dispatch_update(update) end end |
.dispatch_update(update) ⇒ Object
1098 1099 1100 |
# File 'lib/goat.rb', line 1098 def self.dispatch_update(update) StateSrvClient.component_updated(nil, update.skel.pgid, update) end |
.dispatch_updates(txn, pgid, ups) ⇒ Object
1090 1091 1092 1093 1094 1095 1096 |
# File 'lib/goat.rb', line 1090 def self.dispatch_updates(txn, pgid, ups) StateSrvClient.components_updated( txn, pgid, ups ) end |
.enable ⇒ Object
1063 1064 1065 1066 |
# File 'lib/goat.rb', line 1063 def self.enable Goat::NotificationCenter.subscribe(self, :txn_start, 'type' => 'txn_start') Goat::NotificationCenter.subscribe(self, :txn_complete, 'type' => 'txn_complete') end |
.finish_txn(txn_id) ⇒ Object
1082 1083 1084 1085 1086 1087 1088 |
# File 'lib/goat.rb', line 1082 def self.finish_txn(txn_id) if txn = @active_txns[txn_id] pgid = txn[:pgid] dispatch_updates(txn_id, pgid, txn[:page_updates]) txn[:other_updates].each{|u| dispatch_update(u)} end end |
.txn_complete(n) ⇒ Object
1078 1079 1080 |
# File 'lib/goat.rb', line 1078 def self.txn_complete(n) finish_txn(n['txn']) end |
.txn_start(n) ⇒ Object
1070 1071 1072 1073 1074 1075 1076 |
# File 'lib/goat.rb', line 1070 def self.txn_start(n) @active_txns[n['txn']] = { :page_updates => [], :other_updates => [], :pgid => n['pgid'] } end |