Initial commit

This commit is contained in:
Donny
2019-04-22 20:46:32 +08:00
commit 49ab8aadd1
25441 changed files with 4055000 additions and 0 deletions

37
library/net/rpc/liverpc/testdata/BUILD vendored Normal file
View File

@@ -0,0 +1,37 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["client.go"],
importpath = "go-common/library/net/rpc/liverpc/testdata",
tags = ["manual"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/liverpc:go_default_library",
"//library/net/rpc/liverpc/testdata/v1:go_default_library",
"//library/net/rpc/liverpc/testdata/v2:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//library/net/rpc/liverpc/testdata/v1:all-srcs",
"//library/net/rpc/liverpc/testdata/v2:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,46 @@
// Code generated by liverpcgen, DO NOT EDIT.
// source: *.proto files under this directory
// If you want to change this file, Please see README in go-common/app/tool/liverpc/protoc-gen-liverpc/
package testdata
import (
"go-common/library/net/rpc/liverpc"
"go-common/library/net/rpc/liverpc/testdata/v1"
"go-common/library/net/rpc/liverpc/testdata/v2"
)
// Client that represents a liverpc room service api
type Client struct {
cli *liverpc.Client
// V1Room presents the controller in liverpc
V1Room v1.RoomRPCClient
// V2Room presents the controller in liverpc
V2Room v2.RoomRPCClient
}
// DiscoveryAppId the discovery id is not the tree name
var DiscoveryAppId = "live.room"
// New a Client that represents a liverpc live.room service api
// conf can be empty, and it will use discovery to find service by default
// conf.AppID will be overwrite by a fixed value DiscoveryAppId
// therefore is no need to set
func New(conf *liverpc.ClientConfig) *Client {
if conf == nil {
conf = &liverpc.ClientConfig{}
}
conf.AppID = DiscoveryAppId
var realCli = liverpc.NewClient(conf)
cli := &Client{cli: realCli}
cli.clientInit(realCli)
return cli
}
func (cli *Client) GetRawCli() *liverpc.Client {
return cli.cli
}
func (cli *Client) clientInit(realCli *liverpc.Client) {
cli.V1Room = v1.NewRoomRPCClient(realCli)
cli.V2Room = v2.NewRoomRPCClient(realCli)
}

View File

@@ -0,0 +1,53 @@
load(
"@io_bazel_rules_go//proto:def.bzl",
"go_proto_library",
)
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
proto_library(
name = "v1_proto",
srcs = ["Room.proto"],
tags = ["automanaged"],
)
go_proto_library(
name = "v1_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
importpath = "go-common/library/net/rpc/liverpc/testdata/v1",
proto = ":v1_proto",
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["Room.liverpc.go"],
embed = [":v1_go_proto"],
importpath = "go-common/library/net/rpc/liverpc/testdata/v1",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/liverpc:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_golang_protobuf//proto:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,73 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v1/Room.proto
/*
Package v1 is a generated liverpc stub package.
This code was generated with go-common/app/tool/liverpc/protoc-gen-liverpc v0.1.
It is generated from these files:
v1/Room.proto
*/
package v1
import context "context"
import proto "github.com/golang/protobuf/proto"
import "go-common/library/net/rpc/liverpc"
var _ proto.Message // generate to suppress unused imports
// Imports only used by utility functions:
// ==============
// Room Interface
// ==============
type RoomRPCClient interface {
// * 根据房间id获取房间信息
GetInfoById(ctx context.Context, req *RoomGetInfoByIdReq, opts ...liverpc.CallOption) (resp *RoomGetInfoByIdResp, err error)
// * 获取房间基本信息接口,前端/移动端房间页使用
GetInfo(ctx context.Context, req *RoomGetInfoReq, opts ...liverpc.CallOption) (resp *RoomGetInfoResp, err error)
}
// ====================
// Room Live Rpc Client
// ====================
type roomRPCClient struct {
client *liverpc.Client
}
// NewRoomRPCClient creates a client that implements the RoomRPCClient interface.
func NewRoomRPCClient(client *liverpc.Client) RoomRPCClient {
return &roomRPCClient{
client: client,
}
}
func (c *roomRPCClient) GetInfoById(ctx context.Context, in *RoomGetInfoByIdReq, opts ...liverpc.CallOption) (*RoomGetInfoByIdResp, error) {
out := new(RoomGetInfoByIdResp)
err := doRPCRequest(ctx, c.client, 1, "Room.get_info_by_id", in, out, opts)
if err != nil {
return nil, err
}
return out, nil
}
func (c *roomRPCClient) GetInfo(ctx context.Context, in *RoomGetInfoReq, opts ...liverpc.CallOption) (*RoomGetInfoResp, error) {
out := new(RoomGetInfoResp)
err := doRPCRequest(ctx, c.client, 1, "Room.get_info", in, out, opts)
if err != nil {
return nil, err
}
return out, nil
}
// =====
// Utils
// =====
func doRPCRequest(ctx context.Context, client *liverpc.Client, version int, method string, in, out proto.Message, opts []liverpc.CallOption) (err error) {
err = client.Call(ctx, version, method, in, out, opts...)
return
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,119 @@
syntax = "proto3";
package room.v1;
option go_package = "v1";
service Room {
/** 根据房间id获取房间信息
*
*/
rpc get_info_by_id (RoomGetInfoByIdReq) returns (RoomGetInfoByIdResp);
/** 获取房间基本信息接口,前端/移动端房间页使用
*
*/
rpc get_info (RoomGetInfoReq) returns (RoomGetInfoResp);
}
message RoomGetInfoByIdReq {
repeated int64 ids = 1; // 房间id, 可以为短号
repeated string fields = 2; // 需要哪些字段, 不传默认所有
}
message RoomGetInfoByIdResp {
int64 code = 1; // code
string msg = 2; // msg
map<string, RoomInfo> data = 3; // 房间信息map
message RoomInfo {
int64 roomid = 1; // 房间id
string uname = 2; // 用户名, 不可靠.
string cover = 3; // 封面
int64 uid = 4; // 用户id
string live_time = 5; // 开播时间
int64 round_status = 6; // 轮播状态
int64 on_flag = 7; // 是否开播
string title = 8; // 直播间标题
string lock_status = 9; // 锁定到时间
string hidden_status = 10; // 隐藏到时间
string user_cover = 11; // 也是封面...
int64 short_id = 12; // 短号
int64 online = 13; // 在线人数
int64 area = 14; // 分区id
int64 area_v2_id = 15; // 分区v2 id
int64 area_v2_parent_id = 16; // 分区v2 父分区id
string area_v2_name = 17; // 分区v2名字 fields加了该字段才会给
string area_v2_parent_name = 18; // 分区v2父分区名字 fields加了该字段才会给
int64 attentions = 19; // 关注人数
}
}
message RoomGetInfoReq {
int64 id = 1; // 房间号或者短号
string from = 2; // 来源 房间页room link中心 link_center
}
message RoomGetInfoResp {
int64 code = 1; // code
string msg = 2; // msg
Data data = 3; //
message PendantWithDesc {
string name = 1; // 名字、标识
int64 position = 2; // 位置0无1左上2右上3右下4左下
string value = 3; // name对应的value可以是挂件的展示名字/对应的图片地址
string desc = 4; // 描述
}
message Pendant {
string name = 1; // 名字、标识
int64 position = 2; // 位置0无1左上2右上3右下4左下
string value = 3; // name对应的value可以是挂件的展示名字/对应的图片地址
}
message Pendants {
PendantWithDesc frame = 1; // web端房间页头像边框
PendantWithDesc badge = 2; // web端房间页头像角标
Pendant mobile_frame = 3; // 移动端房间页头像边框
Pendant mobile_badge = 4; // 移动端房间页头像角标
}
message Data {
int64 uid = 1; //
int64 room_id = 2; // 房间id
int64 short_id = 3; // 短号
string keyframe = 4; // 关键帧
int64 online = 5; // 在线人数
bool is_portrait = 6; // true为竖屏
string room_silent_type = 7; // 禁言类型 member medal level 或者空字符串
int64 room_silent_second = 8; // 剩余禁言时间,秒数
int64 room_silent_level = 9; // 禁言等级
int64 live_status = 10; // 闲置中0 直播中1 轮播中2
int64 area_id = 11; // 分区id
int64 parent_area_id = 12; // 父分区id
string area_name = 13; // 分区名字
string parent_area_name = 14; // 父分区名字
int64 old_area_id = 15; // 老分区id
string background = 16; // 背景url
string title = 17; // 房间标题
bool is_strict_room = 18; // 是否是限制房间 如果是 应该不连接弹幕 不展示礼物等等
string user_cover = 19; // 房间封面
string live_time = 20; // 开播时间
string pendants = 21; // 挂件列表
string area_pendants = 22; // 分区第一标志, 待定.
string description = 23; // 房间简介.
string tags = 24; // 房间标签, 逗号分隔字符串
string verify = 25; // 认证信息 没认证为空字符串
repeated string hot_words = 26; // 弹幕热词
int64 allow_change_area_time = 27; // 允许修改分区时间戳(主播可能被审核禁止修改分区),0表示没有限制 主播才有此字段
int64 allow_upload_cover_time = 28; // 允许上传封面的时间 0表示没有限制 主播才有此字段gs
Pendants new_pendants = 29; // 新挂件
string up_session = 30; // 一次开播标记
int64 pk_status = 31; // 0为该房间不处于pk中 1表示处于pk中(需调用pk基础信息接口获取pk信息)
}
}

View File

@@ -0,0 +1,53 @@
load(
"@io_bazel_rules_go//proto:def.bzl",
"go_proto_library",
)
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
proto_library(
name = "v2_proto",
srcs = ["Room.proto"],
tags = ["automanaged"],
)
go_proto_library(
name = "v2_go_proto",
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
importpath = "go-common/library/net/rpc/liverpc/testdata/v2",
proto = ":v2_proto",
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["Room.liverpc.go"],
embed = [":v2_go_proto"],
importpath = "go-common/library/net/rpc/liverpc/testdata/v2",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/liverpc:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@com_github_golang_protobuf//proto:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,62 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v2/Room.proto
/*
Package v2 is a generated liverpc stub package.
This code was generated with go-common/app/tool/liverpc/protoc-gen-liverpc v0.1.
It is generated from these files:
v2/Room.proto
*/
package v2
import context "context"
import proto "github.com/golang/protobuf/proto"
import "go-common/library/net/rpc/liverpc"
var _ proto.Message // generate to suppress unused imports
// Imports only used by utility functions:
// ==============
// Room Interface
// ==============
type RoomRPCClient interface {
// * 根据房间id获取房间信息v2
// 修正原来的get_info_by_id 在传了fields字段但是不包含roomid的情况下 依然会返回所有字段, 新版修正这个问题, 只会返回指定的字段.
GetByIds(ctx context.Context, req *RoomGetByIdsReq, opts ...liverpc.CallOption) (resp *RoomGetByIdsResp, err error)
}
// ====================
// Room Live Rpc Client
// ====================
type roomRPCClient struct {
client *liverpc.Client
}
// NewRoomRPCClient creates a client that implements the RoomRPCClient interface.
func NewRoomRPCClient(client *liverpc.Client) RoomRPCClient {
return &roomRPCClient{
client: client,
}
}
func (c *roomRPCClient) GetByIds(ctx context.Context, in *RoomGetByIdsReq, opts ...liverpc.CallOption) (*RoomGetByIdsResp, error) {
out := new(RoomGetByIdsResp)
err := doRPCRequest(ctx, c.client, 2, "Room.get_by_ids", in, out, opts)
if err != nil {
return nil, err
}
return out, nil
}
// =====
// Utils
// =====
func doRPCRequest(ctx context.Context, client *liverpc.Client, version int, method string, in, out proto.Message, opts []liverpc.CallOption) (err error) {
err = client.Call(ctx, version, method, in, out, opts...)
return
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,61 @@
syntax = "proto3";
package room.v2;
option go_package = "v2";
service Room {
/** 根据房间id获取房间信息v2
* 修正原来的get_info_by_id 在传了fields字段但是不包含roomid的情况下 依然会返回所有字段, 新版修正这个问题, 只会返回指定的字段.
*/
rpc get_by_ids (RoomGetByIdsReq) returns (RoomGetByIdsResp);
}
message RoomGetByIdsReq {
repeated int64 ids = 1; // 房间id, 尽可能传长号支持短号eg.短号1->长号40000则返回的房间信息map key是40000
int64 need_uinfo = 2; // 是否需要附加uname、face字段need_uinfo=1 尽量别传,传了请和@小卫报备!!
int64 need_broadcast_type = 3; // 是否需要broadcast_type字段need_broadcast_type=1
repeated string fields = 4; // 需要哪些字段, 不传默认给大多数字段
string from = 5; // 调用方来源英文格式约定部门_服务_业务 eg.live_activity_spring
}
message RoomGetByIdsResp {
int64 code = 1; // code
string msg = 2; // msg
map<string, RoomInfo> data = 3; // 房间信息map
message RoomInfo {
int64 roomid = 1; // 房间id
string uname = 2; // 用户名
string face = 3; // 用户头像
string verify = 4; // 加v认证信息
string cover = 5; // 关键帧 注need_uinfo=1时该字段优先表示封面图
int64 uid = 6; // 用户id
string live_time = 7; // 开播时间
int64 round_status = 8; // 轮播投递状态 1开启 0关闭
int64 on_flag = 9; // 轮播开启状态 1开启 0关闭
string title = 10; // 直播间标题
string tags = 11; // 直播间标签
string lock_status = 12; // 锁定到时间
string hidden_status = 13; // 隐藏到时间
string user_cover = 14; // 封面
int64 short_id = 15; // 短号
int64 online = 16; // 在线人数
int64 area = 17; // 分区id
int64 area_v2_id = 18; // 分区v2 id
int64 area_v2_parent_id = 19; // 分区v2 父分区id
int64 area_pk_status = 20; // 分区是否开放pk 0关闭 1开放
string area_v2_name = 21; // 分区v2名字
string area_v2_parent_name = 22; // 分区v2父分区名字
int64 attentions = 23; // 关注人数
string background = 24; // 房间背景图
int64 room_silent = 25; // 是否静默 0否,1注册会员,2全部
int64 room_shield = 26; // 是否使用房主的屏蔽用户作为房间全局屏蔽用户0不使用1使用
string try_time = 27; // 试用直播间到期时间
int64 live_status = 28; // 直播间状态 0关播 1直播中 2轮播中
int64 broadcast_type = 29; // 横竖屏只有传了need_broadcast_type才会返回 0横屏 1竖屏 -1异常情况
}
}