Synthèse automatique
Intègre les building blocks de Dapr (Pub/Sub, State, Secrets, Service Invocation, Jobs API) pour construire une architecture microservices événementielle.
Points forts
- Configuration simple via fichiers YAML pour chaque building block
- SDK Python bien documenté avec exemples concrets
- Supporte le déploiement local et Kubernetes
- Couverture complète des besoins de communication entre services
Limites
- Nécessite que Dapr soit installé et initialisé sur l'environnement
- La configuration Kafka suppose un broker déjà opérationnel
- Les exemples sont spécifiques à FastAPI, pas génériques pour tous les frameworks
Quand vous implémentez une architecture événementielle avec plusieurs microservices nécessitant messagerie, état partagé, secrets et tâches planifiées.
Pour une application monolithique simple ou lorsque la latence et la surcharge opérationnelle de Dapr ne sont pas justifiées.
Analyse de sécurité
SûrThe skill provides legitimate Dapr integration instructions for development. Commands are standard Dapr operations (init, run, version check) and configuration writing. No destructive, exfiltrating, or obfuscated actions detected.
Aucun point d'attention détecté
Comment cette analyse est faiteExemples
Create a Dapr Pub/Sub component file for Kafka and provide Python code to publish and subscribe to task events using the Dapr SDK.Generate a Dapr state store component file for Redis and show how to save and retrieve task state using the Dapr Python SDK.Initialize Dapr locally, create the necessary component files (pubsub, statestore, secrets), and configure a FastAPI microservice to use them.name: dapr-integration description: Integrate Dapr building blocks for event-driven microservices - Pub/Sub, State Management, Secrets, Service Invocation, and Jobs API. Use when implementing event-driven architecture for Phase 5. (project) allowed-tools: Bash, Write, Read, Glob, Edit, Grep
Dapr Integration Skill
Quick Start
- Read Phase 5 Constitution -
constitution-prompt-phase-5.md - Check Dapr installation -
dapr --version - Initialize Dapr -
dapr initordapr init -kfor Kubernetes - Create component files - In
dapr-components/directory - Configure sidecar - Annotations for Kubernetes deployments
- Test locally -
dapr runcommands
Dapr Building Blocks Overview
| Building Block | Purpose | Phase 5 Usage | |----------------|---------|---------------| | Pub/Sub | Event messaging | Task events, reminders, audit logs | | State | Key-value storage | Cache, session state | | Secrets | Secret management | API keys, DB credentials | | Service Invocation | Service-to-service calls | Microservice communication | | Jobs API | Scheduled tasks | Recurring task scheduling |
Component Configuration
Pub/Sub Component (Kafka)
Create dapr-components/pubsub.yaml:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: taskpubsub
namespace: todo-app
spec:
type: pubsub.kafka
version: v1
metadata:
- name: brokers
value: "kafka:9092"
- name: consumerGroup
value: "todo-consumer-group"
- name: authType
value: "none"
- name: disableTls
value: "true"
scopes:
- backend
- notification-service
- recurring-service
- audit-service
State Store Component
Create dapr-components/statestore.yaml:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: statestore
namespace: todo-app
spec:
type: state.redis
version: v1
metadata:
- name: redisHost
value: "redis:6379"
- name: redisPassword
value: ""
- name: actorStateStore
value: "true"
scopes:
- backend
Secrets Component
Create dapr-components/secrets.yaml:
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: kubernetes-secrets
namespace: todo-app
spec:
type: secretstores.kubernetes
version: v1
metadata: []
Python SDK Integration
Installation
uv add dapr dapr-ext-fastapi
Pub/Sub Publisher
from dapr.clients import DaprClient
async def publish_task_event(event_type: str, task_data: dict):
"""Publish task event to Kafka via Dapr."""
with DaprClient() as client:
client.publish_event(
pubsub_name="taskpubsub",
topic_name="task-events",
data=json.dumps({
"event_type": event_type,
"task": task_data,
"timestamp": datetime.utcnow().isoformat()
}),
data_content_type="application/json"
)
Pub/Sub Subscriber (FastAPI)
from dapr.ext.fastapi import DaprApp
from fastapi import FastAPI
app = FastAPI()
dapr_app = DaprApp(app)
@dapr_app.subscribe(pubsub="taskpubsub", topic="task-events")
async def handle_task_event(event: dict):
"""Handle incoming task events."""
event_type = event.get("event_type")
task_data = event.get("task")
if event_type == "task.created":
await process_new_task(task_data)
elif event_type == "task.completed":
await process_completed_task(task_data)
State Management
from dapr.clients import DaprClient
async def save_state(key: str, value: dict):
"""Save state to Dapr state store."""
with DaprClient() as client:
client.save_state(
store_name="statestore",
key=key,
value=json.dumps(value)
)
async def get_state(key: str) -> dict | None:
"""Get state from Dapr state store."""
with DaprClient() as client:
state = client.get_state(store_name="statestore", key=key)
return json.loads(state.data) if state.data else None
Service Invocation
from dapr.clients import DaprClient
async def invoke_notification_service(user_id: str, message: str):
"""Invoke notification service via Dapr."""
with DaprClient() as client:
response = client.invoke_method(
app_id="notification-service",
method_name="send",
data=json.dumps({
"user_id": user_id,
"message": message
}),
http_verb="POST"
)
return response.json()
Jobs API (Scheduled Tasks)
from dapr.clients import DaprClient
async def schedule_reminder(reminder_id: str, due_at: datetime):
"""Schedule a reminder using Dapr Jobs API."""
with DaprClient() as client:
# Create a scheduled job
client.start_workflow(
workflow_component="dapr",
workflow_name="reminder-workflow",
input={
"reminder_id": reminder_id,
"scheduled_time": due_at.isoformat()
}
)
Kubernetes Deployment Annotations
apiVersion: apps/v1
kind: Deployment
metadata:
name: backend
spec:
template:
metadata:
annotations:
dapr.io/enabled: "true"
dapr.io/app-id: "backend"
dapr.io/app-port: "8000"
dapr.io/enable-api-logging: "true"
dapr.io/log-level: "info"
dapr.io/config: "dapr-config"
spec:
containers:
- name: backend
image: evolution-todo/backend:latest
Local Development with Dapr
Run with Dapr Sidecar
# Run backend with Dapr
dapr run --app-id backend \
--app-port 8000 \
--dapr-http-port 3500 \
--components-path ./dapr-components \
-- uv run uvicorn src.main:app --host 0.0.0.0 --port 8000
# Run notification service with Dapr
dapr run --app-id notification-service \
--app-port 8002 \
--dapr-http-port 3502 \
--components-path ./dapr-components \
-- uv run uvicorn services.notification.main:app --host 0.0.0.0 --port 8002
Test Pub/Sub
# Publish test event
dapr publish --publish-app-id backend \
--pubsub taskpubsub \
--topic task-events \
--data '{"event_type":"task.created","task":{"id":"123","title":"Test"}}'
Verification Checklist
- [ ] Dapr CLI installed (
dapr --version) - [ ] Dapr initialized (
dapr initordapr init -k) - [ ] Component files created in
dapr-components/ - [ ] Python SDK installed (
dapr,dapr-ext-fastapi) - [ ] Pub/Sub working (publish → subscribe)
- [ ] State store working (save → get)
- [ ] Service invocation working
- [ ] Kubernetes annotations configured
- [ ] All services have Dapr sidecars
Event Topics
| Topic | Publisher | Subscribers | Purpose |
|-------|-----------|-------------|---------|
| task-events | Backend | Notification, Audit, WebSocket | Task CRUD events |
| reminder-events | Recurring Service | Notification, Backend | Reminder triggers |
| audit-events | All Services | Audit Service | Audit logging |
Troubleshooting
| Issue | Cause | Solution |
|-------|-------|----------|
| Sidecar not starting | Missing annotations | Add dapr.io/enabled: "true" |
| Pub/Sub not working | Component not loaded | Check component scope |
| Connection refused | Wrong port | Verify app-port matches app |
| State not persisting | Redis not running | Start Redis container |
References
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/dapr-integration-for-event-driven-microservices-mm5t8aa0/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/dapr-integration-for-event-driven-microservices-mm5t8aa0' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/dapr-integration-for-event-driven-microservices-mm5t8aa0/download' --output '.skill-downloads/dapr-integration-for-event-driven-microservices-mm5t8aa0/SKILL.md.part' && mv '.skill-downloads/dapr-integration-for-event-driven-microservices-mm5t8aa0/SKILL.md.part' '.skill-downloads/dapr-integration-for-event-driven-microservices-mm5t8aa0/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Outils déclarés par l’auteur (à vérifier dans votre agent) : Bash, Write, Read, Glob, Edit, Grep
Extrait original : Installation
uv add dapr dapr-ext-fastapi
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.
Claude Code
test -f '.skill-downloads/dapr-integration-for-event-driven-microservices-mm5t8aa0/SKILL.md' && test -s '.skill-downloads/dapr-integration-for-event-driven-microservices-mm5t8aa0/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/dapr-integration' && cp -R '.skill-downloads/dapr-integration-for-event-driven-microservices-mm5t8aa0' '.claude/skills/dapr-integration'OpenSkills
OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.
Installation officielle d’OpenSkillsopenskills install './.skill-downloads/dapr-integration-for-event-driven-microservices-mm5t8aa0'openskills read 'dapr-integration-for-event-driven-microservices-mm5t8aa0'La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.
Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.
openskills syncMode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/dapr-integration-for-event-driven-microservices-mm5t8aa0/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Bonnes pratiques React Hook Form
Developpement
Maîtrisez React Hook Form : évitez les anti-patterns, gérez les abonnements, et traitez correctement reset, dirty state et entrées contrôlées.
Migration Emotion vers Mantine
Developpement
Migrer les styled-components Emotion vers des composants Mantine avec style props et modules CSS. Pour convertir .styled.tsx ou supprimer les imports @emotion.
Détecteur de dérive de périmètre
Developpement
Analyse les diffs git par rapport à une intention pour détecter la dérive de périmètre, fichiers non liés et PR trop larges, puis suggère de garder, diviser ou justifier.