Skip to main content

CockroachDB

Type: state.cockroachdb

Status: stable

Reference: https://docs.dapr.io/reference/components-reference/supported-state-stores/setup-cockroachdb/

Example

apiVersion: cra.diagrid.io/v1beta1
kind: Component
metadata:
name: <name>
spec:
type: state.cockroachdb
version: v1
metadata:
# The connection string for the CockroachDB database
- name: connectionString
value: "host=mycompany.com user=root password=example port=5432 connect_timeout=10 database=dapr_test"
# Interval to clean up rows with an expired TTL. Setting this to values `<=0` disables the periodic cleanup. (Optional)
#- name: cleanupInterval
# value: "1h"
# Max idle time before unused connections are automatically closed in the connection pool. By default, there’s no value and this is left to the database driver to choose. (Optional)
#- name: connectionMaxIdleTime
# value: "5m"
# Use this state store as the Workflows Store, it will enable the Workflows API. Defaults to `false`. (Optional)
#- name: enableWorkflow
# value: "false"
# Prefix added to keys in the state store. (Optional)
#- name: keyPrefix
# value: "appid"
# Name of the table Dapr uses to store a few metadata properties. Can optionally have the schema name as prefix, such as public.dapr_metadata. (Optional)
#- name: metadataTableName
# value: "dapr_metadata"
# By setting outboxDiscardWhenMissingState to true, Dapr discards the transaction if it cannot find the state in the database and does not retry. This setting can be useful if the state store data has been deleted for any reason before Dapr was able to deliver the message and you would like Dapr to drop the items from the pub/sub and stop retrying to fetch the state (Optional)
#- name: outboxDiscardWhenMissingState
# value: "false"
# For outbox. Sets the name of the pub/sub component to deliver the notifications when publishing state changes (Optional)
#- name: outboxPublishPubsub
# value: ""
# For outbox. Sets the topic that receives the state changes on the pub/sub configured with "outboxPublishPubsub". The message body will be a state transaction item for an insert or update operation (Optional)
#- name: outboxPublishTopic
# value: ""
# For outbox. Sets the pub/sub component used by Dapr to coordinate the state and pub/sub transactions. If not set, the pub/sub component configured with "outboxPublishPubsub" is used. This is useful if you want to separate the pub/sub component used to send the notification state changes from the one used to coordinate the transaction (Optional)
#- name: outboxPubsub
# value: "outboxPublishPubsub"
# Name of the table where the data is stored. Can optionally have the schema name as prefix, such as public.state. (Optional)
#- name: tableName
# value: "state"
# Timeout for all database operations. (Optional)
#- name: timeout
# value: "20s"

Authentication profiles

Available authentication profiles:

  • Connection string

Connection string

Authenticate using a Connection String

connectionString (string)

Required - The connection string for the CockroachDB database

Example value: host=mycompany.com user=root password=example port=5432 connect_timeout=10 database=dapr_test

Metadata

cleanupInterval (duration)

Interval to clean up rows with an expired TTL. Setting this to values <=0 disables the periodic cleanup.

Default value: 1h

Example value: 10m, -1

connectionMaxIdleTime (duration)

Max idle time before unused connections are automatically closed in the connection pool. By default, there’s no value and this is left to the database driver to choose.

Example value: 5m

enableWorkflow (bool)

Use this state store as the Workflows Store, it will enable the Workflows API. Defaults to false.

Example value: false

keyPrefix (string)

Prefix added to keys in the state store.

Default value: appid

Example value: appid

Allowed values:

  • appid

  • name

  • none

Documentation: https://docs.dapr.io/developing-applications/building-blocks/state-management/howto-share-state/

metadataTableName (string)

Name of the table Dapr uses to store a few metadata properties. Can optionally have the schema name as prefix, such as public.dapr_metadata.

Default value: dapr_metadata

Example value: dapr_metadata, public.dapr_metadata

outboxDiscardWhenMissingState (bool)

By setting outboxDiscardWhenMissingState to true, Dapr discards the transaction if it cannot find the state in the database and does not retry. This setting can be useful if the state store data has been deleted for any reason before Dapr was able to deliver the message and you would like Dapr to drop the items from the pub/sub and stop retrying to fetch the state

Default value: false

outboxPublishPubsub (string)

For outbox. Sets the name of the pub/sub component to deliver the notifications when publishing state changes

outboxPublishTopic (string)

For outbox. Sets the topic that receives the state changes on the pub/sub configured with "outboxPublishPubsub". The message body will be a state transaction item for an insert or update operation

outboxPubsub (string)

For outbox. Sets the pub/sub component used by Dapr to coordinate the state and pub/sub transactions. If not set, the pub/sub component configured with "outboxPublishPubsub" is used. This is useful if you want to separate the pub/sub component used to send the notification state changes from the one used to coordinate the transaction

Default value: outboxPublishPubsub

tableName (string)

Name of the table where the data is stored. Can optionally have the schema name as prefix, such as public.state.

Default value: state

Example value: state, public.state

timeout (duration)

Timeout for all database operations.

Default value: 20s

Example value: 30s