Welcome to the Subscription Service repository! This guide will help you set up the project environment and complete the assigned tasks related to implementing subscription functionalities.
Before you begin, ensure you have the following installed on your system:
-
Rust (version 1.60 or later)
- Installation: Rust Official Website
-
Cargo (comes bundled with Rust)
- Verification: Run
cargo --version
in your terminal.
- Verification: Run
-
SQLite (version 3.0 or later)
- Installation:
- Ubuntu/Debian:
sudo apt update sudo apt install sqlite3 libsqlite3-dev
- macOS (using Homebrew):
brew install sqlite3
- Windows: Download the precompiled binaries from the SQLite Download Page and follow the installation instructions.
- Ubuntu/Debian:
- Installation:
-
Git (for cloning the repository)
- Installation: Git Official Website
Start by cloning the repository to your local machine:
git clone https://github.com/your-username/subscription-service.git
cd subscription-service
With the dependencies installed and the database initialized, you can now start the gRPC server:
cargo run
You should see logs indicating that the server has started and is listening on the specified port.
Your task involves enhancing the Subscription Service by implementing and extending the list_subscriptions
functionality.
Objective: Finish implementing the list_subscriptions
function to retrieve all subscriptions from the database and test it using Postman.
Steps:
-
Locate the Function:
- Open the file
src/handlers/api.rs
- Find the
list_subscriptions
function, which is currently unimplemented (todo!()
)
- Open the file
-
Implement Database Retrieval:
- Use the appropriate database queries to fetch all email entries from the subscriptions table
- Populate the
ListSubscriptionsResponse
with the retrieved emails
-
Test Using Postman:
- Setup Postman for gRPC
- Create a new request
- Set the request type to gRPC
- Enter the server address (e.g.,
localhost:50051
) - Invoke
ListSubscriptions
- Send the request and verify that all subscriptions are returned correctly
Deliverables:
- A working
list_subscriptions
function that retrieves and returns all subscribed emails - Confirmation of functionality through successful Postman tests
Objective: Enhance the list_subscriptions
functionality by adding the ability to filter subscriptions based on a provided email substring.
Steps:
-
Update the Proto File:
- Open the
.proto
file defining theListSubscriptionsRequest
- Add an optional filter field to allow clients to specify a substring for filtering emails
- Open the
-
Regenerate Rust Code:
- After modifying the proto file, regenerate the Rust code using
tonic-build
or your preferred method
- After modifying the proto file, regenerate the Rust code using
-
Modify the
list_subscriptions
Function:- Update the function to accept the filter parameter
- Adjust the database query to include a condition that filters emails containing the specified substring
-
Test the Filter:
- Using Postman:
- Modify the
ListSubscriptions
request to include a filter value - Send the request and verify that only emails containing the specified substring are returned
- Modify the
- Edge Cases:
- Test with filters that match multiple, single, or no emails to ensure robustness
- Using Postman:
Deliverables:
- An updated
ListSubscriptionsRequest
that includes an optional filter field - Enhanced
list_subscriptions
function capable of filtering results based on the provided email substring - Successful tests demonstrating the filtering functionality