mirror of https://github.com/dapr/docs.git
Standardize PostgreSQL components' name
Fixes #3200 Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com>
This commit is contained in:
parent
86070e6896
commit
2ddf28688c
|
@ -36,7 +36,7 @@ Each of these building block APIs is independent, meaning that you can use one,
|
|||
| Building Block | Description |
|
||||
|----------------|-------------|
|
||||
| [**Service-to-service invocation**]({{< ref "service-invocation-overview.md" >}}) | Resilient service-to-service invocation enables method calls, including retries, on remote services, wherever they are located in the supported hosting environment.
|
||||
| [**State management**]({{< ref "state-management-overview.md" >}}) | With state management for storing and querying key/value pairs, long-running, highly available, stateful services can be easily written alongside stateless services in your application. The state store is pluggable and examples include AWS DynamoDB, Azure CosmosDB, Azure SQL Server, GCP Firebase, PostgreSQL or Redis, among others.
|
||||
| [**State management**]({{< ref "state-management-overview.md" >}}) | With state management for storing and querying key/value pairs, long-running, highly available, stateful services can be easily written alongside stateless services in your application. The state store is pluggable and examples include AWS DynamoDB, Azure Cosmos DB, Azure SQL Server, GCP Firebase, PostgreSQL or Redis, among others.
|
||||
| [**Publish and subscribe**]({{< ref "pubsub-overview.md" >}}) | Publishing events and subscribing to topics between services enables event-driven architectures to simplify horizontal scalability and make them resilient to failure. Dapr provides at-least-once message delivery guarantee, message TTL, consumer groups and other advance features.
|
||||
| [**Resource bindings**]({{< ref "bindings-overview.md" >}}) | Resource bindings with triggers builds further on event-driven architectures for scale and resiliency by receiving and sending events to and from any external source such as databases, queues, file systems, etc.
|
||||
| [**Actors**]({{< ref "actors-overview.md" >}}) | A pattern for stateful and stateless objects that makes concurrency simple, with method and state encapsulation. Dapr provides many capabilities in its actor runtime, including concurrency, state, and life-cycle management for actor activation/deactivation, and timers and reminders to wake up actors.
|
||||
|
|
|
@ -11,7 +11,7 @@ Let's take a look at Dapr's [Bindings building block]({{< ref bindings >}}). Usi
|
|||
- Trigger your app with events coming in from external systems.
|
||||
- Interface with external systems.
|
||||
|
||||
In this Quickstart, you will schedule a batch script to run every 10 seconds using an input [Cron](https://docs.dapr.io/reference/components-reference/supported-bindings/cron/) binding. The script processes a JSON file and outputs data to a SQL database using the [PostgreSQL](https://docs.dapr.io/reference/components-reference/supported-bindings/postgres) Dapr binding.
|
||||
In this Quickstart, you will schedule a batch script to run every 10 seconds using an input [Cron](https://docs.dapr.io/reference/components-reference/supported-bindings/cron/) binding. The script processes a JSON file and outputs data to a SQL database using the [PostgreSQL](https://docs.dapr.io/reference/components-reference/supported-bindings/postgresql) Dapr binding.
|
||||
|
||||
<img src="/images/bindings-quickstart/bindings-quickstart.png" width=800 style="padding-bottom:15px;">
|
||||
|
||||
|
@ -98,7 +98,7 @@ The code inside the `process_batch` function is executed every 10 seconds (defin
|
|||
def process_batch():
|
||||
```
|
||||
|
||||
The `batch-sdk` service uses the PostgreSQL output binding defined in the [`binding-postgres.yaml`]({{< ref "#componentbinding-postgresyaml-component-file" >}}) component to insert the `OrderId`, `Customer`, and `Price` records into the `orders` table.
|
||||
The `batch-sdk` service uses the PostgreSQL output binding defined in the [`binding-postgresql.yaml`]({{< ref "#componentbinding-postgresyaml-component-file" >}}) component to insert the `OrderId`, `Customer`, and `Price` records into the `orders` table.
|
||||
|
||||
```python
|
||||
with DaprClient() as d:
|
||||
|
@ -140,7 +140,7 @@ In a new terminal, verify the same data has been inserted into the database. Nav
|
|||
cd bindings/db
|
||||
```
|
||||
|
||||
Run the following to start the interactive Postgres CLI:
|
||||
Run the following to start the interactive *psql* CLI:
|
||||
|
||||
```bash
|
||||
docker exec -i -t postgres psql --username postgres -p 5432 -h localhost --no-password
|
||||
|
@ -193,16 +193,16 @@ spec:
|
|||
|
||||
**Note:** The `metadata` section of `binding-cron.yaml` contains a [Cron expression]({{< ref cron.md >}}) that specifies how often the binding is invoked.
|
||||
|
||||
#### `component\binding-postgres.yaml` component file
|
||||
#### `component\binding-postgresql.yaml` component file
|
||||
|
||||
When you execute the `dapr run` command and specify the component path, the Dapr sidecar:
|
||||
|
||||
- Initiates the PostgreSQL [binding building block]({{< ref postgres.md >}})
|
||||
- Connects to PostgreSQL using the settings specified in the `binding-postgres.yaml` file
|
||||
- Initiates the PostgreSQL [binding building block]({{< ref postgresql.md >}})
|
||||
- Connects to PostgreSQL using the settings specified in the `binding-postgresql.yaml` file
|
||||
|
||||
With the `binding-postgres.yaml` component, you can easily swap out the backend database [binding]({{< ref supported-bindings.md >}}) without making code changes.
|
||||
With the `binding-postgresql.yaml` component, you can easily swap out the backend database [binding]({{< ref supported-bindings.md >}}) without making code changes.
|
||||
|
||||
The PostgreSQL `binding-postgres.yaml` file included for this Quickstart contains the following:
|
||||
The PostgreSQL `binding-postgresql.yaml` file included for this Quickstart contains the following:
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
|
@ -211,7 +211,7 @@ metadata:
|
|||
name: sqldb
|
||||
namespace: quickstarts
|
||||
spec:
|
||||
type: bindings.postgres
|
||||
type: bindings.postgresql
|
||||
version: v1
|
||||
metadata:
|
||||
- name: url # Required
|
||||
|
@ -304,7 +304,7 @@ async function start() {
|
|||
}
|
||||
```
|
||||
|
||||
The `batch-sdk` service uses the PostgreSQL output binding defined in the [`binding-postgres.yaml`]({{< ref "##componentsbinding-postgresyaml-component-file" >}}) component to insert the `OrderId`, `Customer`, and `Price` records into the `orders` table.
|
||||
The `batch-sdk` service uses the PostgreSQL output binding defined in the [`binding-postgresql.yaml`]({{< ref "##componentsbinding-postgresyaml-component-file" >}}) component to insert the `OrderId`, `Customer`, and `Price` records into the `orders` table.
|
||||
|
||||
```javascript
|
||||
async function processBatch(){
|
||||
|
@ -395,16 +395,16 @@ spec:
|
|||
|
||||
**Note:** The `metadata` section of `binding-cron.yaml` contains a [Cron expression]({{< ref cron.md >}}) that specifies how often the binding is invoked.
|
||||
|
||||
#### `component\binding-postgres.yaml` component file
|
||||
#### `component\binding-postgresql.yaml` component file
|
||||
|
||||
When you execute the `dapr run` command and specify the component path, the Dapr sidecar:
|
||||
|
||||
- Initiates the PostgreSQL [binding building block]({{< ref postgres.md >}})
|
||||
- Connects to PostgreSQL using the settings specified in the `binding-postgres.yaml` file
|
||||
- Initiates the PostgreSQL [binding building block]({{< ref postgresql.md >}})
|
||||
- Connects to PostgreSQL using the settings specified in the `binding-postgresql.yaml` file
|
||||
|
||||
With the `binding-postgres.yaml` component, you can easily swap out the backend database [binding]({{< ref supported-bindings.md >}}) without making code changes.
|
||||
With the `binding-postgresql.yaml` component, you can easily swap out the backend database [binding]({{< ref supported-bindings.md >}}) without making code changes.
|
||||
|
||||
The PostgreSQL `binding-postgres.yaml` file included for this Quickstart contains the following:
|
||||
The PostgreSQL `binding-postgresql.yaml` file included for this Quickstart contains the following:
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
|
@ -413,7 +413,7 @@ metadata:
|
|||
name: sqldb
|
||||
namespace: quickstarts
|
||||
spec:
|
||||
type: bindings.postgres
|
||||
type: bindings.postgresql
|
||||
version: v1
|
||||
metadata:
|
||||
- name: url # Required
|
||||
|
@ -506,7 +506,7 @@ app.MapPost("/" + cronBindingName, async () => {
|
|||
});
|
||||
```
|
||||
|
||||
The `batch-sdk` service uses the PostgreSQL output binding defined in the [`binding-postgres.yaml`]({{< ref "#componentbinding-postgresyaml-component-file" >}}) component to insert the `OrderId`, `Customer`, and `Price` records into the `orders` table.
|
||||
The `batch-sdk` service uses the PostgreSQL output binding defined in the [`binding-postgresql.yaml`]({{< ref "#componentbinding-postgresyaml-component-file" >}}) component to insert the `OrderId`, `Customer`, and `Price` records into the `orders` table.
|
||||
|
||||
```csharp
|
||||
// ...
|
||||
|
@ -599,16 +599,16 @@ spec:
|
|||
|
||||
**Note:** The `metadata` section of `binding-cron.yaml` contains a [Cron expression]({{< ref cron.md >}}) that specifies how often the binding is invoked.
|
||||
|
||||
#### `component\binding-postgres.yaml` component file
|
||||
#### `component\binding-postgresql.yaml` component file
|
||||
|
||||
When you execute the `dapr run` command and specify the component path, the Dapr sidecar:
|
||||
|
||||
- Initiates the PostgreSQL [binding building block]({{< ref postgres.md >}})
|
||||
- Connects to PostgreSQL using the settings specified in the `binding-postgres.yaml` file
|
||||
- Initiates the PostgreSQL [binding building block]({{< ref postgresql.md >}})
|
||||
- Connects to PostgreSQL using the settings specified in the `binding-postgresql.yaml` file
|
||||
|
||||
With the `binding-postgres.yaml` component, you can easily swap out the backend database [binding]({{< ref supported-bindings.md >}}) without making code changes.
|
||||
With the `binding-postgresql.yaml` component, you can easily swap out the backend database [binding]({{< ref supported-bindings.md >}}) without making code changes.
|
||||
|
||||
The PostgreSQL `binding-postgres.yaml` file included for this Quickstart contains the following:
|
||||
The PostgreSQL `binding-postgresql.yaml` file included for this Quickstart contains the following:
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
|
@ -617,7 +617,7 @@ metadata:
|
|||
name: sqldb
|
||||
namespace: quickstarts
|
||||
spec:
|
||||
type: bindings.postgres
|
||||
type: bindings.postgresql
|
||||
version: v1
|
||||
metadata:
|
||||
- name: url # Required
|
||||
|
@ -711,7 +711,7 @@ The code inside the `process_batch` function is executed every 10 seconds (defin
|
|||
public ResponseEntity<String> processBatch() throws IOException, Exception
|
||||
```
|
||||
|
||||
The `batch-sdk` service uses the PostgreSQL output binding defined in the [`binding-postgres.yaml`]({{< ref "#componentbinding-postgresyaml-component-file" >}}) component to insert the `OrderId`, `Customer`, and `Price` records into the `orders` table.
|
||||
The `batch-sdk` service uses the PostgreSQL output binding defined in the [`binding-postgresql.yaml`]({{< ref "#componentbinding-postgresyaml-component-file" >}}) component to insert the `OrderId`, `Customer`, and `Price` records into the `orders` table.
|
||||
|
||||
```java
|
||||
try (DaprClient client = new DaprClientBuilder().build()) {
|
||||
|
@ -809,16 +809,16 @@ spec:
|
|||
|
||||
**Note:** The `metadata` section of `binding-cron.yaml` contains a [Cron expression]({{< ref cron.md >}}) that specifies how often the binding is invoked.
|
||||
|
||||
#### `component\binding-postgres.yaml` component file
|
||||
#### `component\binding-postgresql.yaml` component file
|
||||
|
||||
When you execute the `dapr run` command and specify the component path, the Dapr sidecar:
|
||||
|
||||
- Initiates the PostgreSQL [binding building block]({{< ref postgres.md >}})
|
||||
- Connects to PostgreSQL using the settings specified in the `binding-postgres.yaml` file
|
||||
- Initiates the PostgreSQL [binding building block]({{< ref postgresql.md >}})
|
||||
- Connects to PostgreSQL using the settings specified in the `binding-postgresql.yaml` file
|
||||
|
||||
With the `binding-postgres.yaml` component, you can easily swap out the backend database [binding]({{< ref supported-bindings.md >}}) without making code changes.
|
||||
With the `binding-postgresql.yaml` component, you can easily swap out the backend database [binding]({{< ref supported-bindings.md >}}) without making code changes.
|
||||
|
||||
The PostgreSQL `binding-postgres.yaml` file included for this Quickstart contains the following:
|
||||
The PostgreSQL `binding-postgresql.yaml` file included for this Quickstart contains the following:
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
|
@ -827,7 +827,7 @@ metadata:
|
|||
name: sqldb
|
||||
namespace: quickstarts
|
||||
spec:
|
||||
type: bindings.postgres
|
||||
type: bindings.postgresql
|
||||
version: v1
|
||||
metadata:
|
||||
- name: url # Required
|
||||
|
@ -918,7 +918,7 @@ The code inside the `process_batch` function is executed every 10 seconds (defin
|
|||
r.HandleFunc("/"+cronBindingName, processBatch).Methods("POST")
|
||||
```
|
||||
|
||||
The `batch-sdk` service uses the PostgreSQL output binding defined in the [`binding-postgres.yaml`]({{< ref "#componentbinding-postgresyaml-component-file" >}}) component to insert the `OrderId`, `Customer`, and `Price` records into the `orders` table.
|
||||
The `batch-sdk` service uses the PostgreSQL output binding defined in the [`binding-postgresql.yaml`]({{< ref "#componentbinding-postgresyaml-component-file" >}}) component to insert the `OrderId`, `Customer`, and `Price` records into the `orders` table.
|
||||
|
||||
```go
|
||||
func sqlOutput(order Order) (err error) {
|
||||
|
@ -1021,16 +1021,16 @@ spec:
|
|||
|
||||
**Note:** The `metadata` section of `binding-cron.yaml` contains a [Cron expression]({{< ref cron.md >}}) that specifies how often the binding is invoked.
|
||||
|
||||
#### `component\binding-postgres.yaml` component file
|
||||
#### `component\binding-postgresql.yaml` component file
|
||||
|
||||
When you execute the `dapr run` command and specify the component path, the Dapr sidecar:
|
||||
|
||||
- Initiates the PostgreSQL [binding building block]({{< ref postgres.md >}})
|
||||
- Connects to PostgreSQL using the settings specified in the `binding-postgres.yaml` file
|
||||
- Initiates the PostgreSQL [binding building block]({{< ref postgresql.md >}})
|
||||
- Connects to PostgreSQL using the settings specified in the `binding-postgresql.yaml` file
|
||||
|
||||
With the `binding-postgres.yaml` component, you can easily swap out the backend database [binding]({{< ref supported-bindings.md >}}) without making code changes.
|
||||
With the `binding-postgresql.yaml` component, you can easily swap out the backend database [binding]({{< ref supported-bindings.md >}}) without making code changes.
|
||||
|
||||
The PostgreSQL `binding-postgres.yaml` file included for this Quickstart contains the following:
|
||||
The PostgreSQL `binding-postgresql.yaml` file included for this Quickstart contains the following:
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
|
@ -1039,7 +1039,7 @@ metadata:
|
|||
name: sqldb
|
||||
namespace: quickstarts
|
||||
spec:
|
||||
type: bindings.postgres
|
||||
type: bindings.postgresql
|
||||
version: v1
|
||||
metadata:
|
||||
- name: url # Required
|
||||
|
|
|
@ -4,12 +4,13 @@ title: "PostgreSQL binding spec"
|
|||
linkTitle: "PostgreSQL"
|
||||
description: "Detailed documentation on the PostgreSQL binding component"
|
||||
aliases:
|
||||
- "/operations/components/setup-bindings/supported-bindings/postgresql/"
|
||||
- "/operations/components/setup-bindings/supported-bindings/postgres/"
|
||||
---
|
||||
|
||||
## Component format
|
||||
|
||||
To setup PostgreSQL binding create a component of type `bindings.postgres`. See [this guide]({{< ref "howto-bindings.md#1-create-a-binding" >}}) on how to create and apply a binding configuration.
|
||||
To setup PostgreSQL binding create a component of type `bindings.postgresql`. See [this guide]({{< ref "howto-bindings.md#1-create-a-binding" >}}) on how to create and apply a binding configuration.
|
||||
|
||||
|
||||
```yaml
|
||||
|
@ -18,7 +19,7 @@ kind: Component
|
|||
metadata:
|
||||
name: <NAME>
|
||||
spec:
|
||||
type: bindings.postgres
|
||||
type: bindings.postgresql
|
||||
version: v1
|
||||
metadata:
|
||||
- name: url # Required
|
||||
|
@ -33,7 +34,7 @@ The above example uses secrets as plain strings. It is recommended to use a secr
|
|||
|
||||
| Field | Required | Binding support | Details | Example |
|
||||
|--------------------|:--------:|------------|-----|---------|
|
||||
| url | Y | Output | Postgres connection string See [here](#url-format) for more details | `"user=dapr password=secret host=dapr.example.com port=5432 dbname=dapr sslmode=verify-ca"` |
|
||||
| url | Y | Output | PostgreSQL connection string See [here](#url-format) for more details | `"user=dapr password=secret host=dapr.example.com port=5432 dbname=dapr sslmode=verify-ca"` |
|
||||
|
||||
### URL format
|
||||
|
||||
|
@ -144,8 +145,7 @@ Finally, the `close` operation can be used to explicitly close the DB connection
|
|||
}
|
||||
```
|
||||
|
||||
|
||||
> Note, the PostgreSql binding itself doesn't prevent SQL injection, like with any database application, validate the input before executing query.
|
||||
> Note, the PostgreSQL binding itself doesn't prevent SQL injection, like with any database application, validate the input before executing query.
|
||||
|
||||
## Related links
|
||||
|
|
@ -1,15 +1,16 @@
|
|||
---
|
||||
type: docs
|
||||
title: "Postgres"
|
||||
linkTitle: "Postgres"
|
||||
description: Detailed information on the Postgres configuration store component
|
||||
title: "PostgreSQL"
|
||||
linkTitle: "PostgreSQL"
|
||||
description: Detailed information on the PostgreSQL configuration store component
|
||||
aliases:
|
||||
- "/operations/components/setup-configuration-store/supported-configuration-stores/setup-postgresql/"
|
||||
- "/operations/components/setup-configuration-store/supported-configuration-stores/setup-postgres/"
|
||||
---
|
||||
|
||||
## Component format
|
||||
|
||||
To set up an Postgres configuration store, create a component of type `configuration.postgres`
|
||||
To set up an PostgreSQL configuration store, create a component of type `configuration.postgresql`
|
||||
|
||||
```yaml
|
||||
apiVersion: dapr.io/v1alpha1
|
||||
|
@ -17,7 +18,7 @@ kind: Component
|
|||
metadata:
|
||||
name: <NAME>
|
||||
spec:
|
||||
type: configuration.postgres
|
||||
type: configuration.postgresql
|
||||
version: v1
|
||||
metadata:
|
||||
- name: connectionString
|
||||
|
@ -40,10 +41,10 @@ The above example uses secrets as plain strings. It is recommended to use a secr
|
|||
| connectionString | Y | The connection string for PostgreSQL. Default pool_max_conns = 5 | `"host=localhost user=postgres password=example port=5432 connect_timeout=10 database=dapr_test pool_max_conns=10"`
|
||||
| table | Y | table name for configuration information. | `configTable`
|
||||
|
||||
## Set up Postgres as Configuration Store
|
||||
## Set up PostgreSQL as Configuration Store
|
||||
|
||||
1. Start Postgres Database
|
||||
1. Connect to the Postgres database and setup a configuration table with following schema -
|
||||
1. Start PostgreSQL Database
|
||||
1. Connect to the PostgreSQL database and setup a configuration table with following schema -
|
||||
|
||||
| Field | Datatype | Nullable |Details |
|
||||
|--------------------|:--------:|---------|---------|
|
||||
|
@ -101,13 +102,13 @@ AFTER INSERT OR UPDATE OR DELETE ON configTable
|
|||
7. 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`
|
||||
|
||||
{{% alert title="Note" color="primary" %}}
|
||||
When calling `subscribe` API, `metadata.pgNotifyChannel` should be used to specify the name of the channel to listen for notifications from Postgres configuration store.
|
||||
When calling `subscribe` API, `metadata.pgNotifyChannel` should be used to specify the name of the channel to listen for notifications from PostgreSQL configuration store.
|
||||
|
||||
Any number of keys can be added to a subscription request. Each subscription uses an exclusive database connection. It is strongly recommended to subscribe to multiple keys within a single subscription. This helps optimize the number of connections to the database.
|
||||
|
||||
Example of subscribe HTTP API -
|
||||
```ps
|
||||
curl --location --request GET 'http://<host>:<dapr-http-port>/configuration/postgres/subscribe?key=<keyname1>&key=<keyname2>&metadata.pgNotifyChannel=<channel name>'
|
||||
curl --location --request GET 'http://<host>:<dapr-http-port>/configuration/mypostgresql/subscribe?key=<keyname1>&key=<keyname2>&metadata.pgNotifyChannel=<channel name>'
|
||||
```
|
||||
{{% /alert %}}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ This component allows using PostgreSQL (Postgres) as state store for Dapr.
|
|||
|
||||
## Create a Dapr component
|
||||
|
||||
Create a file called `postgres.yaml`, paste the following and replace the `<CONNECTION STRING>` value with your connection string. The connection string is a standard PostgreSQL connection string. For example, `"host=localhost user=postgres password=example port=5432 connect_timeout=10 database=dapr_test"`. See the PostgreSQL [documentation on database connections](https://www.postgresql.org/docs/current/libpq-connect.html) for information on how to define a connection string.
|
||||
Create a file called `postgresql.yaml`, paste the following and replace the `<CONNECTION STRING>` value with your connection string. The connection string is a standard PostgreSQL connection string. For example, `"host=localhost user=postgres password=example port=5432 connect_timeout=10 database=dapr_test"`. See the PostgreSQL [documentation on database connections](https://www.postgresql.org/docs/current/libpq-connect.html) for information on how to define a connection string.
|
||||
|
||||
If you want to also configure PostgreSQL to store actors, add the `actorStateStore` option as in the example below.
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@
|
|||
features:
|
||||
input: false
|
||||
output: true
|
||||
- component: PostgreSql
|
||||
link: postgres
|
||||
- component: PostgreSQL
|
||||
link: postgresql
|
||||
state: Stable
|
||||
version: v1
|
||||
since: "1.9"
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
state: Stable
|
||||
version: v1
|
||||
since: "1.11"
|
||||
- component: Postgres
|
||||
link: postgres-configuration-store
|
||||
- component: PostgreSQL
|
||||
link: postgresql-configuration-store
|
||||
state: Stable
|
||||
version: v1
|
||||
since: "1.11"
|
||||
|
|
Loading…
Reference in New Issue