Skip to content
Merged
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
5 changes: 2 additions & 3 deletions python/basics/app/0_durable_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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])

"""
Expand Down
14 changes: 9 additions & 5 deletions python/basics/app/1_building_blocks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import uuid
from datetime import timedelta

import restate
Expand Down Expand Up @@ -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])
1 change: 1 addition & 0 deletions python/basics/app/2_virtual_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

"""
Expand Down
1 change: 1 addition & 0 deletions python/basics/app/3_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

"""
Expand Down
2 changes: 1 addition & 1 deletion python/basics/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading