Chapter 8. Project 4: Profile Service with Pub/Sub and Firestore

This chapter delves into the creation of a cloud native, event-driven microservice: the profile service. This profile service will build and continuously update user profiles based on changing facts from the fact service. The architecture will employ Google Pub/Sub for event notifications, Firestore as a serverless database to store user profiles, and Cloud Run for hosting the service.

Note

The code for this chapter is in the profile-service folder of the GitHub repository.

Requirements

Let’s go straight into the requirements.

User Story

Figure 8-1 is the user story you will be focusing on.

Figure 8-1. Project 4 user story

Elaborated Requirements

It is safe to assume that the system has many users and most are not going to make frequent changes to their skills. This means it is more likely for there to be a request for a profile than for facts to be edited.

You can take advantage of this by storing the profile indefinitely once it’s generated and only updating it when a change is made to the facts. This has the advantage of not needing to access the PostgreSQL database every time a profile is requested, meaning you can keep the instance size small and reduce the cost of the facts service.

Therefore, the requirements are as follows:

  • The service should be triggered every time there’s a change in the user facts ...

Get Cloud Native Development with Google Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.