Dai Zhang
08/03/2025, 7:03 AMopal-client publish-data-update $token --src-url http://mybillingserver.com/users --src-config '{"headers":{"authorization":"bearer secret-token"}}'
it only needs a single field named src-url to determine which datasource should be updates.
1. however, when using posgres table as datasource, this url would like to be "url": "postgresql://postgres@example_db:5432/postgres". Does that means I need to put each data source into different database, in a way like 1 table in 1 database mode? It sounds wired.
2. I checked another option to trigger data update. i.e. using OPAL Server REST API. However, this method seems to be wrong when only putting url in request payload like curl ... --header 'Content-Type: application/json' -d '{"entries":[{"url":"postgresql://postgres@example_db:5432/postgres"}]}'. The opal server won't fill the blanks of other field but remain them as empty which cause opal-client failed to fetch data.
3. then i know maybe I should put the whole datasource config entry into the payload. it sounds wired too. Does that mean I should hard-code all the datasouce configuration into my client.
Is there some id or other workflow, e..g I first go somewhere to get the full datasource configure then post the data update. Really confusing, thanks a lot!Ask Inkeep
08/03/2025, 7:03 AMAsk Inkeep
08/03/2025, 7:03 AMpostgresql://postgres@example_db:5432/postgres connects to a database, but you can fetch different data from the same database using different SQL queries . The query field in your fetcher config determines what specific data gets fetched .
2. Complete Configuration Required
When using the REST API, you need to provide the complete configuration, not just the URL (2) . The postgres fetcher requires additional fields beyond just the URL (1) .
Here's the proper structure for a postgres data update via REST API:
{
"entries": [
{
"url": "postgresql://postgres@example_db:5432/postgres",
"config": {
"fetcher": "PostgresFetchProvider",
"query": "SELECT * FROM users WHERE updated_at > NOW() - INTERVAL '1 hour'"
},
"topics": [
"users"
],
"dst_path": "/users"
}
]
}
3. Configuration Management
You have a few options for managing configurations:
*Option 1: Use OPAL_DATA_CONFIG_SOURCES for baseline data* (3)
Set up your initial data sources in OPAL_DATA_CONFIG_SOURCES and use simpler update triggers for incremental changes .
*Option 2: Store configurations in your application*
Keep the full DataSourceEntry configurations in your application and include them when triggering updates (1) .
*Option 3: Use the CLI with full config*
The CLI command you mentioned works because it uses HTTP fetcher by default (2) . For postgres, you'd need:
opal-client publish-data-update $token \
--src-url postgresql://postgres@example_db:5432/postgres \
--src-config '{"fetcher":"PostgresFetchProvider","query":"SELECT * FROM users"}' \
-t users
The key insight is that different fetchers require different configuration fields - HTTP fetcher just needs a URL, but postgres fetcher needs both URL and SQL query (1) .Ask Inkeep
08/03/2025, 7:04 AMOr Weis
08/03/2025, 7:04 AMOr Weis
08/03/2025, 7:05 AMDai Zhang
08/03/2025, 7:14 AMpolicy-store url e.g.Saving fetched data to policy-store: source url='postgresql://admin@opal-postgresql:5432/opal',. I don't know the concept of policy-store in the opal-client side, could you explain it more for me? would there be some conflicts if they save to the same one.Dai Zhang
08/03/2025, 7:15 AMAsk Inkeep
08/03/2025, 7:15 AMAsk Inkeep
08/03/2025, 7:15 AMdst_path field that determines where in the policy store the data gets saved (2) . For example:
{
"url": "postgresql://admin@opal-postgresql:5432/opal",
"config": {
"fetcher": "PostgresFetchProvider",
"query": "SELECT * FROM users;"
},
"dst_path": "/users"
}
{
"url": "postgresql://admin@opal-postgresql:5432/opal",
"config": {
"fetcher": "PostgresFetchProvider",
"query": "SELECT * FROM orders;"
},
"dst_path": "/orders"
}
*No Conflicts*
There are no conflicts when multiple data sources use the same database URL because:
1. Each gets saved to a different dst_path in the policy store
2. The dst_path acts like a namespace - /users and /orders are completely separate
3. Your Rego policies can access the data using these paths: data.users and data.orders
*Policy Store Configuration*
You can configure which policy store OPAL client connects to using OPAL_POLICY_STORE_URL for standalone OPA (3) , or let OPAL manage an inline OPA instance with OPAL_INLINE_OPA_CONFIG (1) .Ask Inkeep
08/03/2025, 7:15 AM