We've seen how Go kit and our own code take an HTTP request with a JSON payload, translate it into a Go struct, invoke the service implementation, and encode the response as a JSON to return to the caller. Now, let's take a deeper look at the persistent storage of the data. The social graph manager is responsible for maintaining the followed/follower relationships between users. There are many options for storing such data, including relational databases, key-value stores, and, of course, graph databases, which may be the most natural. I chose to use a relational database at this stage because it is familiar, reliable, and can support the following necessary operations well:
- Follow
- Unfollow
- Get followers
- Get following
However, if we later discover that we prefer a different data store or extend the relational DB with some caching mechanism, it will be...