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
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 |
# File 'lib/goat.rb', line 961 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
957 958 959 |
# File 'lib/goat.rb', line 957 def self.dispatch_update(update) StateSrvClient.component_updated(nil, update.skel.pgid, update) end |
.dispatch_updates(txn, pgid, ups) ⇒ Object
944 945 946 947 948 949 950 951 952 953 954 955 |
# File 'lib/goat.rb', line 944 def self.dispatch_updates(txn, pgid, ups) pgups = ups.map{|u| u.skel.pgid}.uniq if pgups.size > 1 raise "Got updates for different pages: #{pgups.inspect}" end StateSrvClient.components_updated( txn, pgid, ups ) end |
.enable ⇒ Object
917 918 919 920 |
# File 'lib/goat.rb', line 917 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
936 937 938 939 940 941 942 |
# File 'lib/goat.rb', line 936 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
932 933 934 |
# File 'lib/goat.rb', line 932 def self.txn_complete(n) finish_txn(n['txn']) end |
.txn_start(n) ⇒ Object
924 925 926 927 928 929 930 |
# File 'lib/goat.rb', line 924 def self.txn_start(n) @active_txns[n['txn']] = { :page_updates => [], :other_updates => [], :pgid => n['pgid'] } end |