0% found this document useful (0 votes)
9 views2 pages

Assignment 1

The assignment involves developing a distributed application for managing bank accounts using gRPC and Python, with a focus on implementing a server and client application. The server must handle various operations such as account creation, deposits, and withdrawals while integrating Redis for account data storage. Additionally, the project requires handling concurrency and implementing robust error handling for various scenarios.

Uploaded by

tiancong2013
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

Assignment 1

The assignment involves developing a distributed application for managing bank accounts using gRPC and Python, with a focus on implementing a server and client application. The server must handle various operations such as account creation, deposits, and withdrawals while integrating Redis for account data storage. Additionally, the project requires handling concurrency and implementing robust error handling for various scenarios.

Uploaded by

tiancong2013
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CS 4459/9644:Scalable and Reliable Distributed Systems

Brief Description
In this assignment, you will develop a distributed application for managing bank accounts using
gRPC and Python. A proto file defining the gRPC service and message structures is provided.
The server will manage account information, while the clients will interact with the server to
perform operations such as account creation, deposits, withdrawals, and interest calculations.

This assignment aims to familiarize you with gRPC, Python, Redis, and handling concurrency in
distributed systems.

Each student must complete their own program.

Requirements
1. gRPC Server (server.py)

• Implement a gRPC server using the proto file provided (BankService).


• The server should listen on port 50051.
• The server should expose the following RPC methods:
o CreateAccount: Create a new bank account.
o GetBalance: Retrieve the balance of an account.
o Deposit: Deposit funds into an account.
o Withdraw: Withdraw funds from an account.
o CalculateInterest: Calculate and apply interest to an account balance.
o Handle errors gracefully, such as invalid account IDs or insufficient funds.

2. Redis Integration

• Use Redis to store and manage account information. Redis will serve as a key-value
store:
o Key: Account ID.
o Value: Account data (e.g., account type, balance).
• Redis should handle the following fields:
o account_id: Unique identifier for each account.
o account_type: Specifies if the account is "savings" or "checking."
o balance: Current balance of the account.

3. Client Application
• Implement a client application in Python that connects to the gRPC server and performs
operations using the RPC methods defined in the proto file.
• The client application should:
o Provide the following functions that interact with the gRPC server:
▪ create_account(account_id: str, account_type: str) -> str:
Creates a new account on the server and returns a confirmation message.
▪ get_balance(account_id: str) -> float: Retrieves the balance for
the specified account ID.
▪ deposit(account_id: str, amount: float) -> str: Deposits the
given amount into the specified account and returns a confirmation
message.
▪ withdraw(account_id: str, amount: float) -> str: Withdraws the
given amount from the specified account and returns a confirmation
message.
▪ calculate_interest(account_id: str, annual_interest_rate:
float) -> str: Applies the specified annual interest rate to the account
balance and returns a confirmation message.

4. Concurrency Handling

• Design the server to handle multiple clients simultaneously.


• Implement locking mechanisms to ensure data consistency, especially during updates to
account balances.

5. Error Handling

• Implement robust error handling for the following scenarios:


o Account not found:
▪ Return error code grpc.StatusCode.NOT_FOUND.
▪ Return the message: "Account not found. Please check the account ID."
o Negative deposit or withdrawal amounts:
▪ Return error code grpc.StatusCode.INVALID_ARGUMENT.
▪ Return the message: "Transaction amount must be positive."
o Insufficient funds for withdrawals:
▪ Return error code grpc.StatusCode.FAILED_PRECONDITION.
▪ Return the message: "Insufficient funds for the requested withdrawal."
o Invalid interest rate values:
▪ Return error code grpc.StatusCode.INVALID_ARGUMENT.
▪ Return the message: "Annual interest rate must be a positive value."
• Ensure that the error codes and messages are consistently returned to the client
application.

You might also like