Dapr building block APIs provide consistent interfaces for recurring distributed-application concerns while allowing platform teams to configure swappable implementations. They include service invocation, state management, publish/subscribe, secrets, bindings, actors, configuration management, and workflows. section 7.3.1
On Kubernetes, annotated deployments receive a daprd sidecar that exposes the APIs over HTTP or gRPC on localhost. Component resources connect those APIs to backing infrastructure such as Redis or Kafka. section 7.3.2
A developer workflow typically combines declarative infrastructure with SDK calls:
- Annotate the deployment with dapr.io/enabled and dapr.io/appid so the control plane enables Dapr for the application. section 7.3.2
- Define a component resource naming the API implementation and its connection metadata, such as a Redis state store or Kafka PubSub component. section 7.3.2 section 7.3.5
- Call the local API through the Dapr Go SDK to get or save state and publish events without directly depending on Redis or Kafka clients. section 7.3.5
- Declare subscriptions that connect a PubSub topic to an application route and optionally scope delivery to named services. section 7.3.5
Conference application state and events
An Agenda service uses the Dapr client to call GetState with a statestore name and key, SaveState with serialized data, and PublishEvent with a PubSub name, topic, and event payload. section 7.3.5
Listing 7.1 Dapr Statestore component definition
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
spec:
type: state.redis #1
version: v1
metadata:
- name: keyPrefix
value: name
- name: redisHost #2
value: redis-master:6379
- name: redisPassword #3
secretKeyRef:
name: redis
key: redis-password
auth:
secretStore: kubernetes
Inspect the Kubernetes Component resource that binds the Statestore API to Redis, including its host, password reference, and secret store. section 7.3.2
