Skip to main content

SQL Database (Postgres)

Cosmonic-managed Provider

This is a client that only connects to non-Cosmonic, external services.

PostgreSQL is an incredibly popular, powerful open source relational database. In addition to communicating with Postgres databases, this provider can communicate with anything that supports the Postgres protocol. This includes cloud-managed, relational datastores like Amazon RDS in Postgres mode.

To launch this provider, head to the logic view, click Provider+ and input the following OCI reference URL in the launch provider dialog:

wasmcloud.azurecr.io/sqldb-postgres:0.4.0

Configuration

Configuring this capability provider is a little tricky during the open beta. You must construct a JSON payload, encode it in base64 and then set the config_b64 field of the link definition.

JSON Configuration settings

SettingDescription
uridatabase connection string. Must begin with scheme postgres:// or postgresql://. Example: postgresql://user:password@host:5678?dbname=customers. This URL must be publicly accessible and cannot be a localhost variant or non-routable IP. See URI reference for complete documentation on all the options.
pool.max_connectionsmax size of connection pool. Default is 8.
pool.min_idleminimum number of idle connections in pool. Default is 0. With this default, the provider does not consume resources until needed. If you need fast application startup time, you may wish to set this to 1 or more, and increase max_lifetime_secs to 86400.
pool.max_lifetime_secswhen a connection has reached this age, after it has finished processing its current workload, it is closed instead of being returned to the pool. Default is 7200 (2 hours).
pool.idle_timeout_secsthe amount of time a connection will remain idle in the pool before it is closed. This setting can be useful to reduce billing costs if your database is billed by connection-time. Default is 600 (10 minutes).

For information on how to configure and manage this provider, please see the wasmCloud Postgres provider documentation.