gorse-io / gorse-io/gorse

define proto for gRPC APIs

Open
#387 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
9.8k
Forks
912
Avg merge
2h 35m
Merged PRs (30d)
9

Description

## Description

Define a proto for gRPC API based on existed [RESTful APIs](https://github.com/zhenghaoz/gorse/blob/master/server/rest.go).

## Hints

Hints for request messages.

- Query params are packed to a request message for each API.
- If an API recieves batch of elements, convert request to a stream.

Hints for reponse messages.

- If an API returns a structure, convert response to a message.
- If an API returns a list, wrap response with a message.

The proto file should be located at `protocol/service.proto`.

## Example

The recommend API coudl be defined as:

```proto
service Service {
rpc Recommend(RecommendRequest) returns (RecommendResponse) {}
}

message RecommendRequest {
string user_id = 1;
optional string category = 2;
optional int64 n = 3;
optional int64 offset = 4;
optional string write_back_type = 5;
optional int64 write_back_delay = 6;
}

message RecommendResponse {
repeated string items = 1;
int64 update_time = 2;
}
```

PS: `RecommendResponse` can be used in other APIs such as `GetLatestItems`, `GetPopularItems`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.