# File lib/dynflow/connectors/database.rb, line 6 def initialize(core, world_id, db) @core = core @db = db @world_id = world_id @started = Concurrent::AtomicReference.new end
# File lib/dynflow/connectors/database.rb, line 13 def self.notify_supported?(db) db.class.name == "Sequel::Postgres::Database" end
# File lib/dynflow/connectors/database.rb, line 34 def notify(world_id) @db.notify("world:#{world_id}") end
# File lib/dynflow/connectors/database.rb, line 21 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
# File lib/dynflow/connectors/database.rb, line 17 def started? @started.get end
# File lib/dynflow/connectors/database.rb, line 38 def stop @started.set false notify(@world_id) end