Skip to content

RPC Requirements

PCBZ edited this page Nov 6, 2025 · 11 revisions

Users

BatchGetUserInfo

Overview

Retrieves basic user information (username) for a list of user IDs. Used by Social Graph Service to enrich follower/following lists with usernames.

Endpoint

POST /user-service/batchGetUserInfo

Request Schema

message BatchGetUserInfoRequest {
  repeated int64 user_ids = 1;  // Required: List of user IDs to retrieve (Max: 100)
}

Response Schema

message BatchGetUserInfoResponse {
  map users = 1;     // Map of user_id to user information
  repeated int64 not_found = 2;       // List of user IDs that were not found
  string error_code = 3;              // Error code if request failed
  string error_message = 4;           // Error message if request failed
}

message UserInfo {
  int64 user_id = 1;                  // User ID
  string username = 2;                // Username
}

Success Response Example

{
  "users": {
    "101": {
      "user_id": 101,
      "username": "alice_smith"
    },
    "102": {
      "user_id": 102,
      "username": "bob_jones"
    },
    "103": {
      "user_id": 103,
      "username": "charlie_brown"
    }
  },
  "not_found": [999],
  "error_code": "",
  "error_message": ""
}

Social Graph

GetFollowing()

Overview

Retrieves the list of users that a specified user follows, with optional filtering by minimum follower count and result limiting.

Endpoint

POST /social-graph/getFollowing

Request Schema

message GetFollowingRequest {
  int64 user_id = 1;           // Required: ID of the user whose following list to retrieve
  int32 min_followers = 2;     // Optional: Minimum follower count filter (default: 0)
  int32 limit = 3;             // Optional: Maximum number of users to return (default: 1000)
}

Response Schema

message GetFollowingResponse {
  repeated int64 user_ids = 1;     // List of user IDs that the user follows
  int32 total_count = 2;           // Total count before limit applied
  bool has_more = 3;               // Whether there are more results available
  string error_message = 4;        // Error message if request failed
}

GetFollowers()

Overview

Retrieves the list of users who follow a specified user, used for fan-out operations when a post is created.

Endpoint

POST /social-graph/getFollowers

Request Schema

message GetFollowersRequest {
  int64 user_id = 1;           // Required: ID of the user whose followers to retrieve
  int32 limit = 2;             // Optional: Maximum number of followers to return (default: 1000)
  int32 offset = 3;            // Optional: Pagination offset (default: 0)
}

Response Schema

message GetFollowersResponse {
  repeated int64 user_ids = 1;     // List of follower user IDs
  int32 total_count = 2;           // Total follower count before pagination
  bool has_more = 3;               // Whether there are more results available
  string error_message = 4;        // Error message if request failed
}

GetFollowersCount()

Overview

Retrieves the follower count for a specified user.

Endpoint

POST /social-graph/getFollowersCount

Request Schema

message GetFollowersCountRequest {
  int64 user_id = 1;           // Required: ID of the user whose follower count to retrieve
}

Response Schema

message GetFollowersCountResponse {
  int64 user_id = 1;           // User ID from the request
  int32 followers_count = 2;   // Number of followers this user has
  string error_message = 3;    // Error message if request failed
}

Post Service

BatchGetPosts()

Overview

Efficiently retrieves recent posts from multiple users in a single batch request, optimized for timeline generation.

Endpoint

POST /post-service/batchGetPosts

Request Schema

message BatchGetPostsRequest {
  repeated int64 user_ids = 1;     // Required: List of user IDs whose posts to retrieve
  int32 limit = 2;                 // Optional: Maximum posts per user (default: 50)
}

Response Schema

message BatchGetPostsResponse {
  map<int64, repeated Post> user_posts = 1;
  string error_message = 2;
}

message Post {
  int64 post_id = 1;
  int64 user_id = 2;
  string content = 3;
  int64 timestamp = 4;
}

Clone this wiki locally