Postgres
To set up an Postgres configuration store, create a component of type
Warning
- Start Postgres Database
Field | Datatype | Nullable | Details |
---|---|---|---|
KEY | VARCHAR | N | Holds “Key” of the configuration attribute |
VALUE | VARCHAR | N | Holds Value of the configuration attribute |
VERSION | VARCHAR | N | Holds version of the configuration attribute |
METADATA | JSON | Y | Holds Metadata as JSON |
CREATE TABLE IF NOT EXISTS table_name (
KEY VARCHAR NOT NULL,
VALUE VARCHAR NOT NULL,
METADATA JSON );
- Create a TRIGGER on configuration table. An example function to create a TRIGGER is as follows -
- Create the trigger with data encapsulated in the field labelled as
data
'table',TG_TABLE_NAME,
'action', TG_OP,
'data', data);
- The channel mentioned as attribute to should be used when subscribing for configuration notifications
- Since this is a generic created trigger, map this trigger to
configuration table
- In the subscribe request add an additional metadata field with key as
pgNotifyChannel
and value should be set to samechannel name
mentioned inpg_notify
. From the above example, it should be set toconfig
Note
When calling subscribe
API, should be used to specify the name of the channel to listen for notifications from Postgres configuration store.
Example of subscribe HTTP API -
curl --location --request GET 'http://<host>:<dapr-http-port>/configuration/postgres/subscribe?key=<keyname1>&key=<keyname2>&metadata.pgNotifyChannel=<channel name>'