module CPEE::Message
Public Class Methods
send(type, event, cpee, instance, instance_uuid, instance_name, content={}, backend=nil)
click to toggle source
# File lib/cpee/message.rb, line 42 def self::send(type, event, cpee, instance, instance_uuid, instance_name, content={}, backend=nil) target = '%02i' % CPEE::Message::target topic = ::File::dirname(event) name = ::File::basename(event) payload = { @@who => cpee, @@type + '-url' => File.join(cpee,instance.to_s), @@type => instance, 'topic' => topic, 'type' => type, 'name' => name, 'timestamp' => Time.now.xmlschema(3), 'content' => content } payload[@@type + '-uuid'] = instance_uuid if instance_uuid payload[@@type + '-name'] = instance_name if instance_name backend.publish(type.to_s + ':' + target + ':' + event.to_s, instance.to_s + ' ' + JSON::generate(payload) ) end
send_url(type, event, cpee, content={}, backend)
click to toggle source
# File lib/cpee/message.rb, line 65 def self::send_url(type, event, cpee, content={}, backend) EM.defer do topic = ::File::dirname(event) name = ::File::basename(event) payload = { @@who => cpee, 'topic' => topic, 'type' => type, 'name' => name, 'timestamp' => Time.now.xmlschema(3), 'content' => content } client = Riddl::Client.new(backend) client.post [ Riddl::Parameter::Simple::new('type',type), Riddl::Parameter::Simple::new('topic',topic), Riddl::Parameter::Simple::new('event',name), Riddl::Parameter::Complex::new('notification','application/json',JSON::generate(payload)) ] end end
set_workers(workers)
click to toggle source
# File lib/cpee/message.rb, line 33 def self::set_workers(workers) @@tworkers = (workers < 1 && workers > 99 ? 1 : workers).freeze @@last = -1 end
target()
click to toggle source
# File lib/cpee/message.rb, line 38 def self::target @@last < @@tworkers-1 ? @@last += 1 : @@last = 0 end
type()
click to toggle source
# File lib/cpee/message.rb, line 26 def self::type #{{{ @@type end
type=(it)
click to toggle source
# File lib/cpee/message.rb, line 29 def self::type=(it) #{{{ @@type = it end
who()
click to toggle source
# File lib/cpee/message.rb, line 20 def self::who #{{{ @@who end
who=(it)
click to toggle source
# File lib/cpee/message.rb, line 23 def self::who=(it) #{{{ @@who = it end