Skip to main content

Readers

A reader method is immutable, so any modifications you make to state are ignored.

A reader method is passed a context of type ReaderContext. A ReaderContext can only be used to make calls to other reader methods.

Here's an example of a reader method called Balance on our Account state that returns the account's current balance:

from bank.v1.bank_rbt import Account

class AccountServicer(Account.Servicer):

async def Balance(
self,
context: ReaderContext,
request: BalanceRequest,
) -> BalanceResponse:
return BalanceResponse(balance=self.state.balance)