Postgres

To set up an Postgres configuration store, create a component of type

Warning

  1. Start Postgres Database
FieldDatatypeNullableDetails
KEYVARCHARNHolds “Key” of the configuration attribute
VALUEVARCHARNHolds Value of the configuration attribute
VERSIONVARCHARNHolds version of the configuration attribute
METADATAJSONYHolds Metadata as JSON
  1. CREATE TABLE IF NOT EXISTS table_name (
  2. KEY VARCHAR NOT NULL,
  3. VALUE VARCHAR NOT NULL,
  4. METADATA JSON );
  1. Create a TRIGGER on configuration table. An example function to create a TRIGGER is as follows -
  1. Create the trigger with data encapsulated in the field labelled as data
  1. 'table',TG_TABLE_NAME,
  2. 'action', TG_OP,
  3. 'data', data);
  1. The channel mentioned as attribute to should be used when subscribing for configuration notifications
  2. Since this is a generic created trigger, map this trigger to configuration table
  1. In the subscribe request add an additional metadata field with key as pgNotifyChannel and value should be set to same channel name mentioned in pg_notify. From the above example, it should be set to config

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 -

  1. curl --location --request GET 'http://<host>:<dapr-http-port>/configuration/postgres/subscribe?key=<keyname1>&key=<keyname2>&metadata.pgNotifyChannel=<channel name>'