class Dynflow::Connectors::Database::PostgresListerner
Public Class Methods
new(core, world_id, db)
click to toggle source
# File lib/dynflow/connectors/database.rb, line 7 def initialize(core, world_id, db) @core = core @db = db @world_id = world_id @started = Concurrent::AtomicReference.new end
notify_supported?(db)
click to toggle source
# File lib/dynflow/connectors/database.rb, line 14 def self.notify_supported?(db) db.class.name == "Sequel::Postgres::Database" end
Public Instance Methods
notify(world_id)
click to toggle source
# File lib/dynflow/connectors/database.rb, line 35 def notify(world_id) @db.notify("world:#{world_id}") end
start()
click to toggle source
# File lib/dynflow/connectors/database.rb, line 22 def start @started.set true @thread = Thread.new do @db.listen("world:#{ @world_id }", :loop => true) do if started? @core << :check_inbox else break # the listener is stopped: don't continue listening end end end end
started?()
click to toggle source
# File lib/dynflow/connectors/database.rb, line 18 def started? @started.get end
stop()
click to toggle source
# File lib/dynflow/connectors/database.rb, line 39 def stop @started.set false notify(@world_id) end