bilibili-API-collect/grpc_api/bilibili/broadcast/v1/broadcast.proto
2022-01-31 00:33:38 +08:00

112 lines
3.0 KiB
Protocol Buffer
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

syntax = "proto3";
package bilibili.broadcast.v1;
import "bilibili/rpc/status.proto";
import "google/protobuf/any.proto";
import "google/protobuf/empty.proto";
// broadcast操作对应每个target_path
service Broadcast {
// 用户鉴权
rpc Auth(AuthReq) returns (AuthResp);
// 心跳保活成功心跳为4分45秒重试心跳为30s三次收不到进行重连不超过5分45
rpc Heartbeat(HeartbeatReq) returns (HeartbeatResp);
// 订阅target_path
rpc Subscribe(TargetPath) returns (google.protobuf.Empty);
// 取消订阅target_path
rpc Unsubscribe(TargetPath) returns (google.protobuf.Empty);
// 消息回执
rpc MessageAck(MessageAckReq) returns (google.protobuf.Empty);
}
// broadcast连接隧道
service BroadcastTunnel {
// 创建双向stream连接隧道
rpc CreateTunnel(stream BroadcastFrame) returns (stream BroadcastFrame);
}
//
enum Action {
UNKNOWN = 0; //
UPDATE = 1; //
DELETE = 2; //
}
// 鉴权请求通过authorization验证绑定用户mid
message AuthReq {
// 冷启动id算法uuid重新起启会变
string guid = 1;
// 连接id算法uuid重连会变
string conn_id = 2;
// 最后收到的消息id用于过虑重连后获取未读的消息
int64 last_msg_id = 3;
}
// 鉴权返回
message AuthResp {
}
// target_path:
// "/" Service-Name "/" {method name} 参考 gRPC Request Path
message BroadcastFrame {
// 请求消息信息
FrameOption options = 1;
// 业务target_path
string target_path = 2;
// 业务pb内容
google.protobuf.Any body = 3;
}
// message_id:
// client: 本次连接唯一的消息id可用于回执
// server: 唯一消息id可用于上报或者回执
// sequence:
// client: 客户端应该每次请求时frame seq++会返回对应的对称req/resp
// server: 服务端下行消息只会返回默认值0
message FrameOption {
// 消息id
int64 message_id = 1;
// frame序号
int64 sequence = 2;
// 是否进行消息回执(发出MessageAckReq)
// downstream 上只有服务端设置为true客户端响应
// upstream 上只有客户端设置为true服务端响应
// 响应帧禁止设置is_ack协议上禁止循环
// 通常只有业务帧才可能设置is_ack, 因为协议栈(例如心跳、鉴权)另有响应约定
bool is_ack = 3;
// 业务状态码
bilibili.rpc.Status status = 4;
// 业务ack来源, 仅downstream时候由服务端填写.
string ack_origin = 5;
//
int64 timestamp = 6;
}
// 心跳请求
message HeartbeatReq{
}
// 心跳返回
message HeartbeatResp{
}
// 消息回执
message MessageAckReq {
// 消息id
int64 ack_id = 1;
// ack来源由业务指定用于埋点跟踪
string ack_origin = 2;
// 消息对应的target_path方便业务区分和监控统计
string target_path = 3;
}
// target_path
message TargetPath {
// 需要订阅的target_paths
repeated string target_paths = 1;
}