Module: Goat::StateSrvClient
- Defined in:
- lib/goat/state-srv.rb
Class Method Summary collapse
- .component_updated(txn, pgid, update) ⇒ Object
- .components_update_completed(cs) ⇒ Object
- .components_updated(txn, pgid, updates) ⇒ Object
- .configure(opts = {}) ⇒ Object
- .fetch_component(id) ⇒ Object
- .live_components(cls, spec) ⇒ Object
- .register_page(pgid, user, cs) ⇒ Object
- .schedule ⇒ Object
- .send_message(type, m, sync = false) ⇒ Object
- .update_page(pgid, txn, updates) ⇒ Object
Class Method Details
.component_updated(txn, pgid, update) ⇒ Object
44 45 46 |
# File 'lib/goat/state-srv.rb', line 44 def self.component_updated(txn, pgid, update) components_updated(txn, pgid, [update]) end |
.components_update_completed(cs) ⇒ Object
48 49 50 |
# File 'lib/goat/state-srv.rb', line 48 def self.components_update_completed(cs) puts "Ack for components_updated: #{cs.inspect}" end |
.components_updated(txn, pgid, updates) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/goat/state-srv.rb', line 52 def self.components_updated(txn, pgid, updates) ('components_updated', { 'txn' => txn, 'pgid' => pgid, 'updates' => updates.map(&:to_hash)}, true ) end |
.configure(opts = {}) ⇒ Object
3 4 5 6 |
# File 'lib/goat/state-srv.rb', line 3 def self.configure(opts={}) @host = opts[:host] @port = opts[:port] end |
.fetch_component(id) ⇒ Object
38 39 40 41 42 |
# File 'lib/goat/state-srv.rb', line 38 def self.fetch_component(id) resp = ('fetch_component', {'id' => id}, true) skelhash = JSON.load(resp)['response'] skelhash.empty? ? nil : ComponentSkeleton.from_hash(skelhash) end |
.live_components(cls, spec) ⇒ Object
33 34 35 36 |
# File 'lib/goat/state-srv.rb', line 33 def self.live_components(cls, spec) resp = ('live_components', {'class' => cls, 'spec' => spec}, true) JSON.load(resp)['response'].map{|h| ComponentSkeleton.from_hash(h)} end |
.register_page(pgid, user, cs) ⇒ Object
21 22 23 |
# File 'lib/goat/state-srv.rb', line 21 def self.register_page(pgid, user, cs) ('register_page', 'pgid' => pgid, 'user' => user, 'components' => cs.map(&:to_hash)) end |
.schedule ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/goat/state-srv.rb', line 8 def self.schedule EM.next_tick { StateSrvConnection.connect( @host || '127.0.0.1', @port || 8011 ) } end |
.send_message(type, m, sync = false) ⇒ Object
17 18 19 |
# File 'lib/goat/state-srv.rb', line 17 def self.(type, m, sync=false) StateSrvConnection.(type, m, sync) end |
.update_page(pgid, txn, updates) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/goat/state-srv.rb', line 25 def self.update_page(pgid, txn, updates) ('update_page', 'pgid' => pgid, 'txn' => txn, 'updates' => updates.map(&:to_hash) ) end |