Skip to content

Commit

Permalink
Replace table config with view for postgresql.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
redrick committed Mar 27, 2017
1 parent 1290d7c commit 3c13410
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------

Expand Down
11 changes: 0 additions & 11 deletions sql/tables/tables.sql

This file was deleted.

3 changes: 3 additions & 0 deletions sql/views/views.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CREATE OR REPLACE VIEW @[email protected] 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);

0 comments on commit 3c13410

Please sign in to comment.