Print setup instructions for running the example.
()
| 297 | |
| 298 | |
| 299 | async def setup_instructions(): |
| 300 | """Print setup instructions for running the example.""" |
| 301 | print("\n=== Setup Instructions (Multi-store) ===") |
| 302 | print("\n1. Create components (Redis + PostgreSQL) in ./components:") |
| 303 | print(""" |
| 304 | # Save as components/statestore-redis.yaml |
| 305 | apiVersion: dapr.io/v1alpha1 |
| 306 | kind: Component |
| 307 | metadata: |
| 308 | name: statestore-redis |
| 309 | spec: |
| 310 | type: state.redis |
| 311 | version: v1 |
| 312 | metadata: |
| 313 | - name: redisHost |
| 314 | value: localhost:6379 |
| 315 | - name: redisPassword |
| 316 | value: "" |
| 317 | |
| 318 | # Save as components/statestore-postgres.yaml |
| 319 | apiVersion: dapr.io/v1alpha1 |
| 320 | kind: Component |
| 321 | metadata: |
| 322 | name: statestore-postgres |
| 323 | spec: |
| 324 | type: state.postgresql |
| 325 | version: v2 |
| 326 | metadata: |
| 327 | - name: connectionString |
| 328 | value: "host=localhost user=postgres password=postgres dbname=dapr port=5432" |
| 329 | """) |
| 330 | print(" You can select which one the main demo uses via env var:") |
| 331 | print(" export DAPR_STATE_STORE=statestore-redis # or statestore-postgres") |
| 332 | print(" Start both Redis and PostgreSQL for this multi-store demo:") |
| 333 | print(" docker run -d -p 6379:6379 redis:7-alpine") |
| 334 | print( |
| 335 | " docker run -d -p 5432:5432 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -e POSTGRES_DB=dapr postgres:16-alpine" |
| 336 | ) |
| 337 | |
| 338 | print("\n NOTE: Always use secret references for passwords/keys in production!") |
| 339 | print(" See: https://docs.dapr.io/operations/components/component-secrets/") |
| 340 | |
| 341 | print("\n2. Start Dapr sidecar:") |
| 342 | print( |
| 343 | " dapr run --app-id myapp --dapr-http-port 3500 --dapr-grpc-port 50001 --resources-path ./components" |
| 344 | ) |
| 345 | print("\n IMPORTANT: Always specify --dapr-http-port 3500 to avoid connection errors!") |
| 346 | print( |
| 347 | " If you recreate PostgreSQL while daprd is running, restart daprd or touch the component YAML" |
| 348 | ) |
| 349 | print( |
| 350 | " to trigger a reload, otherwise you may see 'relation " |
| 351 | + '\\"state\\"' |
| 352 | + " does not exist'." |
| 353 | ) |
| 354 | |
| 355 | print("\n3. Run this example:") |
| 356 | print(" python examples/memory/dapr_session_example.py") |
no outgoing calls
no test coverage detected