Skip to content

Commit 230a848

Browse files
[Release] Synchronize for release (#103)
1 parent deac712 commit 230a848

File tree

18 files changed

+65
-64
lines changed

18 files changed

+65
-64
lines changed

bank/backend/src/account_servicer.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class AccountServicer(Account.Servicer):
2424
def authorizer(self):
2525
return allow()
2626

27-
async def Open(
27+
async def open(
2828
self,
2929
context: WriterContext,
3030
request: OpenRequest,
@@ -35,26 +35,26 @@ async def Open(
3535

3636
# We'd like to send the new customer a welcome email, but that can be
3737
# done asynchronously, so we schedule it as a task.
38-
task_id = await self.ref().schedule().WelcomeEmail(context)
38+
task_id = await self.ref().schedule().welcome_email(context)
3939

4040
return OpenResponse(welcome_email_task_id=task_id)
4141

42-
async def Balance(
42+
async def balance(
4343
self,
4444
context: ReaderContext,
4545
request: BalanceRequest,
4646
) -> BalanceResponse:
4747
return BalanceResponse(balance=self.state.balance)
4848

49-
async def Deposit(
49+
async def deposit(
5050
self,
5151
context: WriterContext,
5252
request: DepositRequest,
5353
) -> DepositResponse:
5454
self.state.balance += request.amount
5555
return DepositResponse(updated_balance=self.state.balance)
5656

57-
async def Withdraw(
57+
async def withdraw(
5858
self,
5959
context: WriterContext,
6060
request: WithdrawRequest,
@@ -67,7 +67,7 @@ async def Withdraw(
6767
self.state.balance = updated_balance
6868
return WithdrawResponse(updated_balance=updated_balance)
6969

70-
async def WelcomeEmail(
70+
async def welcome_email(
7171
self,
7272
context: WriterContext,
7373
request: WelcomeEmailRequest,

bank/backend/src/bank_servicer.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class BankServicer(Bank.Servicer):
1919
def authorizer(self):
2020
return allow()
2121

22-
async def SignUp(
22+
async def sign_up(
2323
self,
2424
context: TransactionContext,
2525
request: SignUpRequest,
@@ -31,7 +31,7 @@ async def SignUp(
3131
new_account_id = str(uuid.uuid4())
3232

3333
# Let's go create the account.
34-
account, _ = await Account.Open(
34+
account, _ = await Account.open(
3535
context,
3636
new_account_id,
3737
customer_name=request.customer_name,
@@ -42,15 +42,15 @@ async def SignUp(
4242

4343
return SignUpResponse(account_id=account.state_id)
4444

45-
async def Transfer(
45+
async def transfer(
4646
self,
4747
context: TransactionContext,
4848
request: TransferRequest,
4949
) -> TransferResponse:
5050
from_account = Account.ref(request.from_account_id)
5151
to_account = Account.ref(request.to_account_id)
5252

53-
await from_account.Withdraw(context, amount=request.amount)
54-
await to_account.Deposit(context, amount=request.amount)
53+
await from_account.withdraw(context, amount=request.amount)
54+
await to_account.deposit(context, amount=request.amount)
5555

5656
return TransferResponse()

bank/backend/src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
async def initialize(context: InitializeContext):
1515
bank = Bank.ref(SINGLETON_BANK_ID)
1616

17-
await bank.SignUp(context, customer_name="Initial User")
17+
await bank.sign_up(context, customer_name="Initial User")
1818

1919

2020
async def main():

bank/backend/tests/account_servicer_test.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,28 @@ async def test_basics(self) -> None:
2929
# Create the state machine by calling its constructor. The fact that the
3030
# state machine _has_ a constructor means that this step is required
3131
# before other methods can be called on it.
32-
account, _ = await Account.Open(context, customer_name="Alice")
32+
account, _ = await Account.open(context, customer_name="Alice")
3333

3434
# We can now call methods on the state machine. It should have a balance
3535
# of 0.
36-
response: BalanceResponse = await account.Balance(context)
36+
response: BalanceResponse = await account.balance(context)
3737
self.assertEqual(response.balance, 0)
3838

3939
# When we deposit money, the balance should go up.
40-
await account.Deposit(context, amount=100)
41-
response = await account.Balance(context)
40+
await account.deposit(context, amount=100)
41+
response = await account.balance(context)
4242
self.assertEqual(response.balance, 100)
4343

4444
# When we withdraw money, the balance should go down.
45-
await account.Withdraw(context, amount=60)
46-
response = await account.Balance(context)
45+
await account.withdraw(context, amount=60)
46+
response = await account.balance(context)
4747
self.assertEqual(response.balance, 40)
4848

4949
# When we withdraw too much money, we should get an error.
5050
# Use a helper function here to get a code snippet for use in docs.
5151
async def withdraw():
5252
try:
53-
await account.Withdraw(context, amount=65)
53+
await account.withdraw(context, amount=65)
5454
except Account.WithdrawAborted as aborted:
5555
match aborted.error:
5656
case OverdraftError(amount=amount):
@@ -67,7 +67,7 @@ async def withdraw():
6767
self.assertTrue(isinstance(aborted.exception.error, OverdraftError))
6868
self.assertEqual(aborted.exception.error.amount, 25)
6969
# ... and the balance shouldn't have changed.
70-
response = await account.Balance(context)
70+
response = await account.balance(context)
7171
self.assertEqual(response.balance, 40)
7272

7373
@mock.patch("account_servicer.send_email")
@@ -87,7 +87,7 @@ async def test_send_welcome_email(self, mock_send_email) -> None:
8787

8888
# When we open an account, we expect the user to receive a welcome
8989
# email.
90-
account, open_response = await Account.Open(
90+
account, open_response = await Account.open(
9191
context,
9292
customer_name="Alice",
9393
)

bank/backend/tests/bank_servicer_test.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ async def test_signup(self) -> None:
2626

2727
# The Bank state machine doesn't have a constructor, so we can simply
2828
# start calling methods on it.
29-
response: SignUpResponse = await bank.SignUp(
29+
response: SignUpResponse = await bank.sign_up(
3030
context,
3131
customer_name="Alice",
3232
)
3333

3434
# SignUp will have created an Account we can call.
3535
account = Account.ref(response.account_id)
36-
response = await account.Balance(context)
36+
response = await account.balance(context)
3737
self.assertEqual(response.balance, 0)
3838

3939
async def test_transfer(self):
@@ -43,37 +43,37 @@ async def test_transfer(self):
4343
context = self.rbt.create_external_context(name=f"test-{self.id()}")
4444
bank = Bank.ref("my-bank")
4545

46-
alice: SignUpResponse = await bank.SignUp(
46+
alice: SignUpResponse = await bank.sign_up(
4747
context,
4848
customer_name="Alice",
4949
)
5050
alice_account = Account.ref(alice.account_id)
51-
bob: SignUpResponse = await bank.SignUp(
51+
bob: SignUpResponse = await bank.sign_up(
5252
context,
5353
customer_name="Bob",
5454
)
5555
bob_account = Account.ref(bob.account_id)
5656

5757
# Alice deposits some money.
58-
await alice_account.Deposit(context, amount=100)
59-
response: BalanceResponse = await alice_account.Balance(context)
58+
await alice_account.deposit(context, amount=100)
59+
response: BalanceResponse = await alice_account.balance(context)
6060
self.assertEqual(response.balance, 100)
6161

6262
# Alice transfers some money to Bob.
63-
await bank.Transfer(
63+
await bank.transfer(
6464
context,
6565
from_account_id=alice.account_id,
6666
to_account_id=bob.account_id,
6767
amount=40,
6868
)
69-
response = await alice_account.Balance(context)
69+
response = await alice_account.balance(context)
7070
self.assertEqual(response.balance, 60)
71-
response = await bob_account.Balance(context)
71+
response = await bob_account.balance(context)
7272
self.assertEqual(response.balance, 40)
7373

7474
# Bob tries to transfer too much money back to Alice.
7575
with self.assertRaises(Bank.TransferAborted) as aborted:
76-
await bank.Transfer(
76+
await bank.transfer(
7777
context,
7878
from_account_id=bob.account_id,
7979
to_account_id=alice.account_id,

hello-constructors/backend/src/hello_servicer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ class HelloServicer(Hello.Servicer):
1616
def authorizer(self):
1717
return allow()
1818

19-
async def Create(
19+
async def create(
2020
self,
2121
context: WriterContext,
2222
request: CreateRequest,
2323
) -> CreateResponse:
2424
self.state.messages.extend([request.initial_message])
2525
return CreateResponse()
2626

27-
async def Messages(
27+
async def messages(
2828
self,
2929
context: ReaderContext,
3030
request: MessagesRequest,
3131
) -> MessagesResponse:
3232
return MessagesResponse(messages=self.state.messages)
3333

34-
async def Send(
34+
async def send(
3535
self,
3636
context: WriterContext,
3737
request: SendRequest,

hello-constructors/backend/src/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212

1313
async def initialize(context: InitializeContext):
1414
# Explicitly create the state machine.
15-
hello, _ = await Hello.Create(
15+
hello, _ = await Hello.create(
1616
context,
1717
EXAMPLE_STATE_MACHINE_ID,
1818
initial_message="Welcome! This message was sent by a constructor.",
1919
)
2020

2121
# Send a message.
22-
await hello.Send(
22+
await hello.send(
2323
context,
2424
message="This message was sent after construction!",
2525
)
2626

27-
messages_response = await hello.Messages(context)
27+
messages_response = await hello.messages(context)
2828
print(
2929
f"After initialization, the Hello messages are: {messages_response.messages}"
3030
)

hello-constructors/backend/tests/hello_servicer_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ async def test_hello_constructors(self) -> None:
2222
# Create the state machine by calling its constructor. The fact that the
2323
# state machine _has_ a constructor means that this step is required
2424
# before other methods can be called on it.
25-
hello, _ = await Hello.Create(context, initial_message="first message")
25+
hello, _ = await Hello.create(context, initial_message="first message")
2626

2727
# Send another message.
28-
await hello.Send(context, message="second message")
28+
await hello.send(context, message="second message")
2929

30-
messages_response = await hello.Messages(context)
30+
messages_response = await hello.messages(context)
3131
self.assertEqual(
3232
messages_response.messages, [
3333
"first message",

hello-legacy-grpc/backend/src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ async def initialize(context: InitializeContext):
1414
# NOTE: we don't need to `spawn()` because we want to immediately
1515
# wait for it to complete (this is syntactic sugar for spawning
1616
# and then awaiting the returned task).
17-
await RebootGreeter.ref("my-greeter").Initialize(context)
17+
await RebootGreeter.ref("my-greeter").initialize(context)
1818

1919

2020
async def main():

hello-legacy-grpc/backend/src/reboot_greeter_servicer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ async def _get_deprecated_salutation(self, context: Context) -> str:
4949
)
5050
return salutation_response.salutation
5151

52-
async def Greet(
52+
async def greet(
5353
self,
5454
context: WriterContext,
5555
request: GreetRequest,
@@ -66,7 +66,7 @@ async def Greet(
6666
f"by the Reboot service."
6767
)
6868

69-
async def GetSalutation(
69+
async def get_salutation(
7070
self,
7171
context: ReaderContext,
7272
request: Empty,
@@ -76,7 +76,7 @@ async def GetSalutation(
7676
salutation = await self._get_deprecated_salutation(context)
7777
return GetSalutationResponse(salutation=salutation)
7878

79-
async def Initialize(
79+
async def initialize(
8080
self,
8181
context: WorkflowContext,
8282
request: Empty,

0 commit comments

Comments
 (0)