Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Using Buf to manage Protobuf #67

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
# protocol
# protocol

## Using Buf to manage Protobuf

## Install

https://buf.build/docs/installation

## Generate

```shell
# generate code
buf generate

# lint
buf lint
```
375 changes: 97 additions & 278 deletions auth/auth.pb.go

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions auth/auth.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ syntax = "proto3";
package OpenIMServer.auth;
option go_package = "github.com/OpenIMSDK/protocol/auth";

import "google/api/annotations.proto";

message userTokenReq {
string secret = 1;
Expand Down Expand Up @@ -55,13 +56,21 @@ message getUserTokenResp{

service Auth {
//生成token
rpc userToken(userTokenReq) returns(userTokenResp);
rpc userToken(userTokenReq) returns(userTokenResp){
option (google.api.http) = {post: "/auth/user_token", body: "*"};
};
// 管理员获取用户 token
rpc getUserToken(getUserTokenReq)returns(getUserTokenResp);
rpc getUserToken(getUserTokenReq)returns(getUserTokenResp){
option (google.api.http) = {post: "/auth/get_user_token", body: "*"};
};
//强制退出登录
rpc forceLogout(forceLogoutReq) returns(forceLogoutResp);
rpc forceLogout(forceLogoutReq) returns(forceLogoutResp){
option (google.api.http) = {post: "/auth/force_logout", body: "*"};
};
//解析token
rpc parseToken(parseTokenReq)returns(parseTokenResp);
rpc parseToken(parseTokenReq)returns(parseTokenResp){
option (google.api.http) = {post: "/auth/parse_token", body: "*"};
};
}


240 changes: 240 additions & 0 deletions auth/auth_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: v1
managed:
enabled: true
go_package_prefix:
default: github.com/OpenIMSDK/protocol
except:
- buf.build/googleapis/googleapis
- buf.build/openim/api
plugins:
- plugin: buf.build/protocolbuffers/go:v1.33.0
out: .
opt: paths=source_relative
- name: go-grpc
out: .
opt:
- paths=source_relative
- require_unimplemented_servers=false
13 changes: 13 additions & 0 deletions buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: ee48893a270147348e3edc6c1a03de0e
digest: shake256:a35b0576a2b55dad72747e786af05c03539c2b96be236c9de39fe10d551931ac252eb68445c0cef6bbd27fa20e8c26eee5b8a9fe9c2fde6f63a03e18f8cf980d
- remote: buf.build
owner: openim
repository: api
commit: 8027e1f68e4e4f43a1cb1f841d340afb
digest: shake256:fbd2f506655acf567d5bd82f270eb696331a243dd7bc6c52050e8ab2aab84e3daa1ff90e369917333a0376335ad5c69537bdc6b352fc4927a7ecc6bcd7f7496c
10 changes: 10 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v1
deps:
- buf.build/googleapis/googleapis
- buf.build/openim/api
breaking:
use:
- FILE
lint:
use:
- DEFAULT
Loading