diff --git a/python/basics/app/0_durable_execution.py b/python/basics/app/0_durable_execution.py index a8340654..398c543e 100644 --- a/python/basics/app/0_durable_execution.py +++ b/python/basics/app/0_durable_execution.py @@ -49,7 +49,7 @@ async def add(ctx: Context, req: SubscriptionRequest): create_recurring_payment, credit_card=req.credit_card, payment_id=payment_id - ), + ) for subscription in req.subscriptions: await ctx.run_typed( @@ -61,8 +61,7 @@ async def add(ctx: Context, req: SubscriptionRequest): ) -# Create an HTTP endpoint to serve your services on port 9080 -# or use .handler() to run on Lambda, Deno, Bun, Cloudflare Workers, ... +# Define 'app' used by hypercorn (or other HTTP servers) to serve the SDK app = restate.app([subscription_service]) """ diff --git a/python/basics/app/1_building_blocks.py b/python/basics/app/1_building_blocks.py index 4384b5e5..59e13856 100644 --- a/python/basics/app/1_building_blocks.py +++ b/python/basics/app/1_building_blocks.py @@ -1,4 +1,3 @@ -import uuid from datetime import timedelta import restate @@ -70,7 +69,12 @@ async def run(ctx: restate.Context): # Then use these to call other APIs and let them deduplicate payment_deduplication_id = str(ctx.uuid()) - result = await ctx.run_typed("charge", - charge_bank_account, - payment_deduplication_id=payment_deduplication_id, - amount=100) + result = await ctx.run_typed( + "charge", + charge_bank_account, + payment_deduplication_id=payment_deduplication_id, + amount=100) + + +# Define 'app' used by hypercorn (or other HTTP servers) to serve the SDK +app = restate.app([my_service, subscription_service]) diff --git a/python/basics/app/2_virtual_objects.py b/python/basics/app/2_virtual_objects.py index 06fa3389..5afd17a5 100644 --- a/python/basics/app/2_virtual_objects.py +++ b/python/basics/app/2_virtual_objects.py @@ -37,6 +37,7 @@ async def ungreet(ctx: ObjectContext) -> str: return f"Goodbye {ctx.key()}, taking one greeting back: {count}." +# Define 'app' used by hypercorn (or other HTTP servers) to serve the SDK app = restate.app(services=[greeter_object]) """ diff --git a/python/basics/app/3_workflows.py b/python/basics/app/3_workflows.py index 9ac98b7c..22ba2327 100644 --- a/python/basics/app/3_workflows.py +++ b/python/basics/app/3_workflows.py @@ -49,6 +49,7 @@ async def click(ctx: WorkflowSharedContext, secret: str): await ctx.promise("link_clicked").resolve(secret) +# Define 'app' used by hypercorn (or other HTTP servers) to serve the SDK app = restate.app(services=[user_signup]) """ diff --git a/python/basics/app/utils.py b/python/basics/app/utils.py index c5f986d7..830c2144 100644 --- a/python/basics/app/utils.py +++ b/python/basics/app/utils.py @@ -25,7 +25,7 @@ def create_subscription(user_id: str, subscription: str, payment_ref: str) -> st # Simulates calling a payment API, with a random probability of API downtime. -def create_recurring_payment(_credit_card: str, payment_id: str) -> str: +def create_recurring_payment(credit_card: str, payment_id: str) -> str: maybe_crash(0.3) print(f">>> Creating recurring payment {payment_id}") return "payment-reference"