32. postgresql.conf設定例(抜粋)
shared_preload_libraries = 'hb_worker'
hb_worker.conninfo = 'dbname=postgres'
サーバ起動例
[nuko]$ pg_ctl start -D ~/pgdata/9.3
server starting
LOG: registering background worker "hb_worker"
LOG: loaded library "hb_worker"
LOG: database system was shut down at 2013-11-05 22:42:28 PST
LOG: starting background worker process "hb_worker"
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
LOG: hb_worker conninfo = dbname=postgres
LOG: hb_worker: set secret number=4539
33. psqlからの実行例
postgres=# LISTEN HB_CL;
LISTEN
postgres=# NOTIFY HB_SV,'xxxx';;
NOTIFY
Asynchronous notification "hb_cl"
received from server process with
postgres=# NOTIFY HB_SV,'0123';;
NOTIFY
Asynchronous notification "hb_cl"
received from server process with
postgres=# NOTIFY HB_SV,'0813';;
NOTIFY
Asynchronous notification "hb_cl"
received from server process with
postgres=#
with payload "Invalid data.(xxxx)"
PID 29520.
with payload "2 Hit / 1 Blow."
PID 29520.
with payload "4 Hit! Conguratulatoins!, next new game."
PID 29520.
(注:見やすさのために適宜改行している)
hb_workerの応答
LOG:
LOG:
NOTIFY HB_CL,'2 Hit / 1 Blow.'
hb_worker: NOTIFY HB_CL,'4 Hit! Conguratulatoins!, next new game.'
LOG:
hb_worker: set secret number=0391