Sha256: 749b53f125fb429a6aaa9d75ba4e12b251ca841ea44e09fd82f849a3ebcb38d4

Contents?: true

Size: 563 Bytes

Versions: 113

Compression:

Stored size: 563 Bytes

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'polyphony/adapters/postgres'

opts = {
  host:     '/tmp',
  user:     'reality',
  password: nil,
  dbname:   'reality',
  sslmode:  'require'
}

db1 = PG.connect(opts)
db2 = PG.connect(opts)

spin_loop {
  STDOUT << '.'
  sleep 0.1
}

db1.query('listen foo')
spin_loop {
  db1.wait_for_notify(1) { |channel, _, msg| puts "\n#{msg}" }
  STDOUT << '?'
}

spin_loop {
  sql = format("notify foo, %s", db2.escape_literal(Time.now.to_s))
  db2.query(sql)
  STDOUT << '!'
  sleep rand(1.5..3)
}

suspend

Version data entries

113 entries across 113 versions & 1 rubygems

Version Path
polyphony-1.6 examples/adapters/pg_notify.rb
polyphony-1.5 examples/adapters/pg_notify.rb
polyphony-1.4 examples/adapters/pg_notify.rb
polyphony-1.3 examples/adapters/pg_notify.rb
polyphony-1.2.1 examples/adapters/pg_notify.rb
polyphony-1.2 examples/adapters/pg_notify.rb
polyphony-1.1.1 examples/adapters/pg_notify.rb
polyphony-1.1 examples/adapters/pg_notify.rb
polyphony-1.0.2 examples/adapters/pg_notify.rb
polyphony-1.0.1 examples/adapters/pg_notify.rb
polyphony-1.0 examples/adapters/pg_notify.rb
polyphony-0.99.6 examples/adapters/pg_notify.rb
polyphony-0.99.5 examples/adapters/pg_notify.rb
polyphony-0.99.4 examples/adapters/pg_notify.rb
polyphony-0.99.3 examples/adapters/pg_notify.rb
polyphony-0.99.2 examples/adapters/pg_notify.rb
polyphony-0.99.1 examples/adapters/pg_notify.rb
polyphony-0.99 examples/adapters/pg_notify.rb
polyphony-0.98 examples/adapters/pg_notify.rb
polyphony-0.97 examples/adapters/pg_notify.rb