Skip to content

Commit eaa117d

Browse files
Fix python basics:
* Make sure app is defined in all the examples, as described in the readme * Fix issues
1 parent db776c6 commit eaa117d

File tree

5 files changed

+14
-9
lines changed

5 files changed

+14
-9
lines changed

python/basics/app/0_durable_execution.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async def add(ctx: Context, req: SubscriptionRequest):
4949
create_recurring_payment,
5050
credit_card=req.credit_card,
5151
payment_id=payment_id
52-
),
52+
)
5353

5454
for subscription in req.subscriptions:
5555
await ctx.run_typed(
@@ -61,8 +61,7 @@ async def add(ctx: Context, req: SubscriptionRequest):
6161
)
6262

6363

64-
# Create an HTTP endpoint to serve your services on port 9080
65-
# or use .handler() to run on Lambda, Deno, Bun, Cloudflare Workers, ...
64+
# Define 'app' used by hypercorn (or other HTTP servers) to serve the SDK
6665
app = restate.app([subscription_service])
6766

6867
"""

python/basics/app/1_building_blocks.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import uuid
21
from datetime import timedelta
32

43
import restate
@@ -70,7 +69,12 @@ async def run(ctx: restate.Context):
7069
# Then use these to call other APIs and let them deduplicate
7170
payment_deduplication_id = str(ctx.uuid())
7271

73-
result = await ctx.run_typed("charge",
74-
charge_bank_account,
75-
payment_deduplication_id=payment_deduplication_id,
76-
amount=100)
72+
result = await ctx.run_typed(
73+
"charge",
74+
charge_bank_account,
75+
payment_deduplication_id=payment_deduplication_id,
76+
amount=100)
77+
78+
79+
# Define 'app' used by hypercorn (or other HTTP servers) to serve the SDK
80+
app = restate.app([my_service, subscription_service])

python/basics/app/2_virtual_objects.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ async def ungreet(ctx: ObjectContext) -> str:
3737
return f"Goodbye {ctx.key()}, taking one greeting back: {count}."
3838

3939

40+
# Define 'app' used by hypercorn (or other HTTP servers) to serve the SDK
4041
app = restate.app(services=[greeter_object])
4142

4243
"""

python/basics/app/3_workflows.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ async def click(ctx: WorkflowSharedContext, secret: str):
4949
await ctx.promise("link_clicked").resolve(secret)
5050

5151

52+
# Define 'app' used by hypercorn (or other HTTP servers) to serve the SDK
5253
app = restate.app(services=[user_signup])
5354

5455
"""

python/basics/app/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def create_subscription(user_id: str, subscription: str, payment_ref: str) -> st
2525

2626

2727
# Simulates calling a payment API, with a random probability of API downtime.
28-
def create_recurring_payment(_credit_card: str, payment_id: str) -> str:
28+
def create_recurring_payment(credit_card: str, payment_id: str) -> str:
2929
maybe_crash(0.3)
3030
print(f">>> Creating recurring payment {payment_id}")
3131
return "payment-reference"

0 commit comments

Comments
 (0)