diff --git a/Makefile b/Makefile index 89885e2..da2d473 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ OBJS = src/pg_amqp.o \ all: sql/$(EXTENSION)--$(EXTVERSION).sql -sql/$(EXTENSION)--$(EXTVERSION).sql: sql/tables/*.sql sql/functions/*.sql +sql/$(EXTENSION)--$(EXTVERSION).sql: sql/views/*.sql sql/functions/*.sql cat $^ > $@ DATA = $(wildcard updates/*--*.sql) sql/$(EXTENSION)--$(EXTVERSION).sql diff --git a/README.md b/README.md index df42975..034a1f7 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,38 @@ To update to the latest version, run the following command after running "make i ALTER EXTENSION amqp UPDATE; +Setup +----- + +Once you are all set, you can enter your credentials to `postgresql.conf` + +This file is under you local postgres installation, e.g. ubuntu PostgreSQL 9.6 +location may be: `/etc/postgresql/9.6/main/postgresql.conf` + +format of the data is as follows: + +``` +amqp.broker = '[{ "broker_id": 1, "host": "px8.uol.cz", "port": "5670", +"vhost": "", "username": "expert", "password": "expert" }]' +``` + +This way you can enter how many configurations you want dividing your broker +configuration with comma like this: + +``` +amqp.broker = '[{ "broker_id": 1, "host": "host.cz", "port": "5672", +"vhost": "/", "username": "username", "password": "password" }, +{ "broker_id": 2, "host": "host.cz", "port": "5672", +"vhost": "/", "username": "username", "password": "password" }]' +``` + +After changes in postgresql.conf you have to restart postgresql service, on +ubunutu look like this: + +``` +service postgresql restart +``` + Basic Usage ----------- diff --git a/sql/tables/tables.sql b/sql/tables/tables.sql deleted file mode 100644 index 5edf6ff..0000000 --- a/sql/tables/tables.sql +++ /dev/null @@ -1,11 +0,0 @@ -CREATE TABLE @extschema@.broker ( - broker_id serial NOT NULL, - host text NOT NULL, - port integer NOT NULL DEFAULT 5672, - vhost text, - username text, - password text, - PRIMARY KEY (broker_id, host, port) -); - - diff --git a/sql/views/views.sql b/sql/views/views.sql new file mode 100644 index 0000000..12332ae --- /dev/null +++ b/sql/views/views.sql @@ -0,0 +1,3 @@ +CREATE OR REPLACE VIEW @extschema@.broker AS +select * from json_to_recordset(current_setting('amqp.broker')::json) +as x(broker_id int, host text, port int, vhost text, username text, password text);