Sha256: 7bea458a888006f7fc4c269603b116dc2892b47d45b486a07f405708da6eaa5d

Contents?: true

Size: 554 Bytes

Versions: 3

Compression:

Stored size: 554 Bytes

Contents

# frozen_string_literal: true

require 'bundler/setup'
require 'polyphony/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

3 entries across 3 versions & 1 rubygems

Version Path
polyphony-0.30 examples/interfaces/pg_notify.rb
polyphony-0.29 examples/interfaces/pg_notify.rb
polyphony-0.28 examples/interfaces/pg_notify.rb