Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ The `examples/` directory serves as the **user-facing documentation**. Each exam
2. Tests use a `DaprRunner` helper (defined in `tests/examples/conftest.py`) that wraps `dapr run` commands
3. `DaprRunner.run()` executes a command and captures stdout; `DaprRunner.start()`/`stop()` manage background services
4. Tests assert that expected output lines appear in the captured output
5. The runner pins every sidecar listener port the test didn't set itself and blocks until those ports are bindable before launching. Test-pinned ports must stay below 32768 — see the "Port allocation" section in `tests/integration/AGENTS.md` for the full rationale.

Run examples locally (requires a running Dapr runtime via `dapr init`):

Expand Down
6 changes: 3 additions & 3 deletions examples/grpc_proxying/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ sleep: 5
-->

```bash
# 1. Start Receiver (expose gRPC server receiver on port 50051)
dapr run --app-id invoke-receiver --app-protocol grpc --app-port 50051 --config config.yaml -- python invoke-receiver.py
# 1. Start Receiver (expose gRPC server receiver on port 13551)
dapr run --app-id invoke-receiver --app-protocol grpc --app-port 13551 --config config.yaml -- python invoke-receiver.py
```

<!-- END_STEP -->
Expand All @@ -51,7 +51,7 @@ sleep: 5

```bash
# 2. Start Caller
dapr run --app-id invoke-caller --dapr-grpc-port 50007 --config config.yaml -- python invoke-caller.py
dapr run --app-id invoke-caller --dapr-grpc-port 13507 --config config.yaml -- python invoke-caller.py
```

<!-- END_STEP -->
Expand Down
4 changes: 2 additions & 2 deletions examples/grpc_proxying/deploy/invoke-receiver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ spec:
dapr.io/enabled: "true"
dapr.io/app-id: "invoke-receiver"
dapr.io/app-protocol: "grpc"
dapr.io/app-port: "50051"
dapr.io/app-port: "13551"
spec:
containers:
- name: invokereceiver
image: invokegrpcproxy:latest # EDIT HERE: Replace the image name
command: ["python"]
args: ["/app/invoke-receiver.py"]
ports:
- containerPort: 50051
- containerPort: 13551
imagePullPolicy: Always
2 changes: 1 addition & 1 deletion examples/grpc_proxying/invoke-caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


async def run() -> None:
async with grpc.aio.insecure_channel('127.0.0.1:50007') as channel:
async with grpc.aio.insecure_channel('127.0.0.1:13507') as channel:
metadata = (('dapr-app-id', 'invoke-receiver'),)
stub = helloworld_service_pb2_grpc.HelloWorldServiceStub(channel)
response = await stub.SayHello(request=HelloRequest(name='you'), metadata=metadata)
Expand Down
2 changes: 1 addition & 1 deletion examples/grpc_proxying/invoke-receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def SayHello(self, request: HelloRequest, context: grpc.aio.ServicerContext) ->
app.add_external_service(
helloworld_service_pb2_grpc.add_HelloWorldServiceServicer_to_server, HelloWorldService()
)
app.run(50051)
app.run(13551)
4 changes: 2 additions & 2 deletions examples/invoke-binding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ background: true
sleep: 5
-->

2. Start Receiver (expose gRPC server receiver on port 50051)
2. Start Receiver (expose gRPC server receiver on port 13551)

```bash
dapr run --app-id receiver --app-protocol grpc --app-port 50051 --resources-path ./components -- python3 invoke-input-binding.py
dapr run --app-id receiver --app-protocol grpc --app-port 13551 --resources-path ./components -- python3 invoke-input-binding.py
```

<!-- END_STEP -->
Expand Down
2 changes: 1 addition & 1 deletion examples/invoke-binding/invoke-input-binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ def binding(request: BindingRequest):
print(request.text(), flush=True)


app.run(50051)
app.run(13551)
4 changes: 2 additions & 2 deletions examples/invoke-custom-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ To run this example, the following steps should be followed:
python3 -m grpc_tools.protoc --proto_path=./proto/ --python_out=./proto/ --grpc_python_out=./proto/ ./proto/response.proto
```

2. Start Receiver (expose gRPC server receiver on port 50051)
2. Start Receiver (expose gRPC server receiver on port 13551)

<!-- STEP
name: Run receiver
Expand All @@ -39,7 +39,7 @@ sleep: 5
-->

```bash
dapr run --app-id invoke-receiver --app-protocol grpc --app-port 50051 -- python3 invoke-receiver.py
dapr run --app-id invoke-receiver --app-protocol grpc --app-port 13551 -- python3 invoke-receiver.py
```

<!-- END_STEP -->
Expand Down
2 changes: 1 addition & 1 deletion examples/invoke-custom-data/invoke-receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ def mymethod(request: InvokeMethodRequest):
)


app.run(50051)
app.run(13551)
4 changes: 2 additions & 2 deletions examples/invoke-simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ sleep: 5
-->

```bash
# 1. Start Receiver (expose gRPC server receiver on port 50051)
dapr run --app-id invoke-receiver --app-protocol grpc --app-port 50051 -- python3 invoke-receiver.py
# 1. Start Receiver (expose gRPC server receiver on port 13551)
dapr run --app-id invoke-receiver --app-protocol grpc --app-port 13551 -- python3 invoke-receiver.py
```

<!-- END_STEP -->
Expand Down
2 changes: 1 addition & 1 deletion examples/invoke-simple/deploy/invoke-receiver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ spec:
dapr.io/enabled: "true"
dapr.io/app-id: "invoke-receiver"
dapr.io/app-protocol: "grpc"
dapr.io/app-port: "50051"
dapr.io/app-port: "13551"
spec:
containers:
- name: invokereceiver
Expand Down
2 changes: 1 addition & 1 deletion examples/invoke-simple/invoke-receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ def mymethod(request: InvokeMethodRequest) -> InvokeMethodResponse:
return InvokeMethodResponse(b'INVOKE_RECEIVED', 'text/plain; charset=UTF-8')


app.run(50051)
app.run(13551)
8 changes: 4 additions & 4 deletions examples/jobs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ Run the following command in a terminal/command-prompt:
name: Run complete workflow example
expected_stdout_lines:
- "Dapr Jobs Example"
- "Starting gRPC server on port 50051..."
- "Starting gRPC server on port 13551..."
- "Scheduling jobs..."
- "✓ hello-job scheduled"
- "✓ data-job scheduled"
Expand All @@ -94,7 +94,7 @@ sleep: 15

```bash
# Start the complete workflow example (schedules jobs and handles job events)
dapr run --app-id jobs-workflow --app-protocol grpc --app-port 50051 -- python3 job_processing.py
dapr run --app-id jobs-workflow --app-protocol grpc --app-port 13551 -- python3 job_processing.py
```

<!-- END_STEP -->
Expand Down Expand Up @@ -239,13 +239,13 @@ def handle_my_job(job_event: JobEvent) -> None:
print(f"Job data: {data_str}")
# Process the job...

app.run(50051)
app.run(13551)
```

The callback service must:
- Use the `@app.job_event('job-name')` decorator to register handlers
- Accept a `JobEvent` object parameter containing job execution data
- Run on a gRPC port (default 50051) that Dapr can reach
- Run on a gRPC port (default 13551) that Dapr can reach

## Additional Information

Expand Down
4 changes: 2 additions & 2 deletions examples/jobs/job_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,5 @@ def schedule_jobs():
# Schedule jobs in a background thread after server starts
threading.Thread(target=schedule_jobs, daemon=True).start()

print('Starting gRPC server on port 50051...', flush=True)
app.run(50051)
print('Starting gRPC server on port 13551...', flush=True)
app.run(13551)
4 changes: 2 additions & 2 deletions examples/pubsub-simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ sleep: 3
-->

```bash
# 1. Start Subscriber (expose gRPC server receiver on port 50051)
dapr run --app-id python-subscriber --app-protocol grpc --app-port 50051 -- python3 subscriber.py
# 1. Start Subscriber (expose gRPC server receiver on port 13551)
dapr run --app-id python-subscriber --app-protocol grpc --app-port 13551 -- python3 subscriber.py
```

<!-- END_STEP -->
Expand Down
2 changes: 1 addition & 1 deletion examples/pubsub-simple/subscriber.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ def mytopic_wildcard(event: SubscriptionMessage) -> TopicEventResponse:

app.register_health_check(lambda: print('Healthy'))

app.run(50051)
app.run(13551)
Loading