Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

87
app/service/live/BUILD Normal file
View File

@@ -0,0 +1,87 @@
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/activity:all-srcs",
"//app/service/live/av:all-srcs",
"//app/service/live/banned_service:all-srcs",
"//app/service/live/broadcast-proxy:all-srcs",
"//app/service/live/captcha:all-srcs",
"//app/service/live/common:all-srcs",
"//app/service/live/dao-anchor/api/grpc/v0:all-srcs",
"//app/service/live/dao-anchor/api/grpc/v1:all-srcs",
"//app/service/live/dao-anchor/cmd:all-srcs",
"//app/service/live/dao-anchor/conf:all-srcs",
"//app/service/live/dao-anchor/dao:all-srcs",
"//app/service/live/dao-anchor/model:all-srcs",
"//app/service/live/dao-anchor/server/grpc:all-srcs",
"//app/service/live/dao-anchor/server/http:all-srcs",
"//app/service/live/dao-anchor/service:all-srcs",
"//app/service/live/fans_medal:all-srcs",
"//app/service/live/gift:all-srcs",
"//app/service/live/grpc-demo:all-srcs",
"//app/service/live/live-dm:all-srcs",
"//app/service/live/live_data/api/liverpc:all-srcs",
"//app/service/live/live_riskcontrol:all-srcs",
"//app/service/live/live_user:all-srcs",
"//app/service/live/rankdb:all-srcs",
"//app/service/live/rc/api/liverpc:all-srcs",
"//app/service/live/recommend:all-srcs",
"//app/service/live/relation/api/liverpc:all-srcs",
"//app/service/live/resource:all-srcs",
"//app/service/live/room/api/liverpc:all-srcs",
"//app/service/live/room_ex/api/liverpc:all-srcs",
"//app/service/live/rtc:all-srcs",
"//app/service/live/third_api:all-srcs",
"//app/service/live/user/api/liverpc:all-srcs",
"//app/service/live/userexp:all-srcs",
"//app/service/live/userext/api/liverpc:all-srcs",
"//app/service/live/wallet:all-srcs",
"//app/service/live/xanchor:all-srcs",
"//app/service/live/xcaptcha:all-srcs",
"//app/service/live/xfansmedal:all-srcs",
"//app/service/live/xlottery:all-srcs",
"//app/service/live/xrewardcenter:all-srcs",
"//app/service/live/xroom-feed/api:all-srcs",
"//app/service/live/xroom-feed/cmd:all-srcs",
"//app/service/live/xroom-feed/internal/dao:all-srcs",
"//app/service/live/xroom-feed/internal/model:all-srcs",
"//app/service/live/xroom-feed/internal/server/grpc:all-srcs",
"//app/service/live/xroom-feed/internal/server/http:all-srcs",
"//app/service/live/xroom-feed/internal/service:all-srcs",
"//app/service/live/xroom/api:all-srcs",
"//app/service/live/xroom/cmd:all-srcs",
"//app/service/live/xroom/internal/dao:all-srcs",
"//app/service/live/xroom/internal/model:all-srcs",
"//app/service/live/xroom/internal/server/grpc:all-srcs",
"//app/service/live/xroom/internal/server/http:all-srcs",
"//app/service/live/xroom/internal/service:all-srcs",
"//app/service/live/xuser:all-srcs",
"//app/service/live/xuserex/api/grpc/v1:all-srcs",
"//app/service/live/xuserex/cmd:all-srcs",
"//app/service/live/xuserex/conf:all-srcs",
"//app/service/live/xuserex/dao:all-srcs",
"//app/service/live/xuserex/model:all-srcs",
"//app/service/live/xuserex/server/grpc:all-srcs",
"//app/service/live/xuserex/server/http:all-srcs",
"//app/service/live/xuserex/service:all-srcs",
"//app/service/live/zeus/api/v1:all-srcs",
"//app/service/live/zeus/cmd:all-srcs",
"//app/service/live/zeus/expr:all-srcs",
"//app/service/live/zeus/internal/conf:all-srcs",
"//app/service/live/zeus/internal/dao:all-srcs",
"//app/service/live/zeus/internal/model:all-srcs",
"//app/service/live/zeus/internal/server/grpc:all-srcs",
"//app/service/live/zeus/internal/server/http:all-srcs",
"//app/service/live/zeus/internal/service:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,6 @@
# Owner
liuzhen
lidongyang
xiehaishen
zhaohailin
yangbaibing

11
app/service/live/OWNERS Normal file
View File

@@ -0,0 +1,11 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- lidongyang
- liuzhen
- xiehaishen
- yangbaibing
- zhaohailin
labels:
- live
- service

View File

@@ -0,0 +1,16 @@
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/activity/api/liverpc:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,3 @@
### v1.0.1
1. 友爱社接口

View File

@@ -0,0 +1,7 @@
# Owner
longsifan
# Author
longsifan
# Reviewer
zhaohailin

View File

@@ -0,0 +1,13 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- longsifan
labels:
- live
- service
- service/live/activity
options:
no_parent_owners: true
reviewers:
- longsifan
- zhaohailin

View File

@@ -0,0 +1,13 @@
# xuser-service
## 项目简介
1.直播活动服务,目前包含
## 编译环境
## 依赖包
## 编译执行

View File

@@ -0,0 +1,35 @@
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/app/service/live/activity/api/liverpc",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/live/activity/api/liverpc/v1:go_default_library",
"//library/net/rpc/liverpc:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/activity/api/liverpc/v1:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,42 @@
// 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 liverpc
import (
"go-common/app/service/live/activity/api/liverpc/v1"
"go-common/library/net/rpc/liverpc"
)
// Client that represents a liverpc activity service api
type Client struct {
cli *liverpc.Client
// V1UnionFans presents the controller in liverpc
V1UnionFans v1.UnionFans
}
// DiscoveryAppId the discovery id is not the tree name
var DiscoveryAppId = "live.activity"
// New a Client that represents a liverpc live.activity 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.V1UnionFans = v1.NewUnionFansRpcClient(realCli)
}

View File

@@ -0,0 +1,56 @@
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 = ["UnionFans.proto"],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "v1_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/service/live/activity/api/liverpc/v1",
proto = ":v1_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = ["UnionFans.liverpc.go"],
embed = [":v1_go_proto"],
importpath = "go-common/app/service/live/activity/api/liverpc/v1",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/liverpc:go_default_library",
"@com_github_gogo_protobuf//gogoproto: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,76 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v1/UnionFans.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/UnionFans.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:
// ===================
// UnionFans Interface
// ===================
type UnionFans interface {
// * 获取友爱社礼包提示
//
GetSendGift(context.Context, *UnionFansGetSendGiftReq) (*UnionFansGetSendGiftResp, error)
// * 查询用户特殊勋章样式
//
GetSpecialMedal(context.Context, *UnionFansGetSpecialMedalReq) (*UnionFansGetSpecialMedalResp, error)
}
// =========================
// UnionFans Live Rpc Client
// =========================
type unionFansRpcClient struct {
client *liverpc.Client
}
// NewUnionFansRpcClient creates a Rpc client that implements the UnionFans interface.
// It communicates using Rpc and can be configured with a custom HTTPClient.
func NewUnionFansRpcClient(client *liverpc.Client) UnionFans {
return &unionFansRpcClient{
client: client,
}
}
func (c *unionFansRpcClient) GetSendGift(ctx context.Context, in *UnionFansGetSendGiftReq) (*UnionFansGetSendGiftResp, error) {
out := new(UnionFansGetSendGiftResp)
err := doRpcRequest(ctx, c.client, 1, "UnionFans.getSendGift", in, out)
if err != nil {
return nil, err
}
return out, nil
}
func (c *unionFansRpcClient) GetSpecialMedal(ctx context.Context, in *UnionFansGetSpecialMedalReq) (*UnionFansGetSpecialMedalResp, error) {
out := new(UnionFansGetSpecialMedalResp)
err := doRpcRequest(ctx, c.client, 1, "UnionFans.getSpecialMedal", in, out)
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) (err error) {
err = client.Call(ctx, version, method, in, out)
return
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,75 @@
syntax = "proto3";
package activity.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service UnionFans {
/** 获取友爱社礼包提示
*
*/
rpc getSendGift (UnionFansGetSendGiftReq) returns (UnionFansGetSendGiftResp);
/** 查询用户特殊勋章样式
*
*/
rpc getSpecialMedal (UnionFansGetSpecialMedalReq) returns (UnionFansGetSpecialMedalResp);
}
message UnionFansGetSendGiftReq {
//
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
}
message UnionFansGetSendGiftResp {
// code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
repeated Data data = 3 [(gogoproto.jsontag) = "data"];
message GiftList {
//
string gift_id = 1 [(gogoproto.jsontag) = "gift_id"];
//
int64 gift_num = 2 [(gogoproto.jsontag) = "gift_num"];
}
message Data {
// 类型
int64 type = 1 [(gogoproto.jsontag) = "type"];
// 名称
string giftTypeName = 2 [(gogoproto.jsontag) = "giftTypeName"];
//
repeated GiftList gift_list = 3 [(gogoproto.jsontag) = "gift_list"];
}
}
message UnionFansGetSpecialMedalReq {
// 用户uid
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
// 主播uid
int64 ruid = 2 [(gogoproto.jsontag) = "ruid"];
}
message UnionFansGetSpecialMedalResp {
// code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
// 特殊序章样式 为空或者为union
string special_medal = 1 [(gogoproto.jsontag) = "special_medal"];
}
}

16
app/service/live/av/BUILD Normal file
View File

@@ -0,0 +1,16 @@
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/av/api/liverpc:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

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/app/service/live/av/api/liverpc",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/live/av/api/liverpc/v0:go_default_library",
"//app/service/live/av/api/liverpc/v1:go_default_library",
"//library/net/rpc/liverpc:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/av/api/liverpc/v0:all-srcs",
"//app/service/live/av/api/liverpc/v1:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,52 @@
// 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 liverpc
import (
"go-common/app/service/live/av/api/liverpc/v0"
"go-common/app/service/live/av/api/liverpc/v1"
"go-common/library/net/rpc/liverpc"
)
// Client that represents a liverpc av service api
type Client struct {
cli *liverpc.Client
// V0PayGoods presents the controller in liverpc
V0PayGoods v0.PayGoods
// V0PayLive presents the controller in liverpc
V0PayLive v0.PayLive
// V1PayLive presents the controller in liverpc
V1PayLive v1.PayLive
// V1Pk presents the controller in liverpc
V1Pk v1.Pk
}
// DiscoveryAppId the discovery id is not the tree name
var DiscoveryAppId = "live.av"
// New a Client that represents a liverpc live.av 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.V0PayGoods = v0.NewPayGoodsRpcClient(realCli)
cli.V0PayLive = v0.NewPayLiveRpcClient(realCli)
cli.V1PayLive = v1.NewPayLiveRpcClient(realCli)
cli.V1Pk = v1.NewPkRpcClient(realCli)
}

View File

@@ -0,0 +1,62 @@
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 = "v0_proto",
srcs = [
"PayGoods.proto",
"PayLive.proto",
],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "v0_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/service/live/av/api/liverpc/v0",
proto = ":v0_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = [
"PayGoods.liverpc.go",
"PayLive.liverpc.go",
],
embed = [":v0_go_proto"],
importpath = "go-common/app/service/live/av/api/liverpc/v0",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/liverpc:go_default_library",
"@com_github_gogo_protobuf//gogoproto: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,116 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v0/PayGoods.proto
/*
Package v0 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:
v0/PayGoods.proto
v0/PayLive.proto
*/
package v0
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:
// ==================
// PayGoods Interface
// ==================
type PayGoods interface {
// * 生成一张付费直播票
//
Add(context.Context, *PayGoodsAddReq) (*PayGoodsAddResp, error)
// * 更新一张付费直播票
//
Update(context.Context, *PayGoodsUpdateReq) (*PayGoodsUpdateResp, error)
// * 获取付费直播票列表
//
GetList(context.Context, *PayGoodsGetListReq) (*PayGoodsGetListResp, error)
// * 关闭购票
//
Close(context.Context, *PayGoodsCloseReq) (*PayGoodsCloseResp, error)
// * 开启购票
//
Open(context.Context, *PayGoodsOpenReq) (*PayGoodsOpenResp, error)
}
// ========================
// PayGoods Live Rpc Client
// ========================
type payGoodsRpcClient struct {
client *liverpc.Client
}
// NewPayGoodsRpcClient creates a Rpc client that implements the PayGoods interface.
// It communicates using Rpc and can be configured with a custom HTTPClient.
func NewPayGoodsRpcClient(client *liverpc.Client) PayGoods {
return &payGoodsRpcClient{
client: client,
}
}
func (c *payGoodsRpcClient) Add(ctx context.Context, in *PayGoodsAddReq) (*PayGoodsAddResp, error) {
out := new(PayGoodsAddResp)
err := doRpcRequest(ctx, c.client, 0, "PayGoods.add", in, out)
if err != nil {
return nil, err
}
return out, nil
}
func (c *payGoodsRpcClient) Update(ctx context.Context, in *PayGoodsUpdateReq) (*PayGoodsUpdateResp, error) {
out := new(PayGoodsUpdateResp)
err := doRpcRequest(ctx, c.client, 0, "PayGoods.update", in, out)
if err != nil {
return nil, err
}
return out, nil
}
func (c *payGoodsRpcClient) GetList(ctx context.Context, in *PayGoodsGetListReq) (*PayGoodsGetListResp, error) {
out := new(PayGoodsGetListResp)
err := doRpcRequest(ctx, c.client, 0, "PayGoods.getList", in, out)
if err != nil {
return nil, err
}
return out, nil
}
func (c *payGoodsRpcClient) Close(ctx context.Context, in *PayGoodsCloseReq) (*PayGoodsCloseResp, error) {
out := new(PayGoodsCloseResp)
err := doRpcRequest(ctx, c.client, 0, "PayGoods.close", in, out)
if err != nil {
return nil, err
}
return out, nil
}
func (c *payGoodsRpcClient) Open(ctx context.Context, in *PayGoodsOpenReq) (*PayGoodsOpenResp, error) {
out := new(PayGoodsOpenResp)
err := doRpcRequest(ctx, c.client, 0, "PayGoods.open", in, out)
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) (err error) {
err = client.Call(ctx, version, method, in, out)
return
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,204 @@
syntax = "proto3";
package av.v0;
option go_package = "v0";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service PayGoods {
/** 生成一张付费直播票
*
*/
rpc add (PayGoodsAddReq) returns (PayGoodsAddResp);
/** 更新一张付费直播票
*
*/
rpc update (PayGoodsUpdateReq) returns (PayGoodsUpdateResp);
/** 获取付费直播票列表
*
*/
rpc getList (PayGoodsGetListReq) returns (PayGoodsGetListResp);
/** 关闭购票
*
*/
rpc close (PayGoodsCloseReq) returns (PayGoodsCloseResp);
/** 开启购票
*
*/
rpc open (PayGoodsOpenReq) returns (PayGoodsOpenResp);
}
message PayGoodsAddReq {
// 平台
string platform = 1 [(gogoproto.jsontag) = "platform"];
// 商品名称
string title = 2 [(gogoproto.jsontag) = "title"];
// 商品类型 2 付费直播门票
int64 type = 3 [(gogoproto.jsontag) = "type"];
// 商品价格(分)
int64 price = 4 [(gogoproto.jsontag) = "price"];
// 开始时间
string start_time = 5 [(gogoproto.jsontag) = "start_time"];
// 结束时间
string end_time = 6 [(gogoproto.jsontag) = "end_time"];
// ip限制0不限制1仅限大陆2仅限港澳台3大陆+港澳台
int64 ip_limit = 7 [(gogoproto.jsontag) = "ip_limit"];
}
message PayGoodsAddResp {
// 返回code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// 返回msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
// 返回data
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
}
}
message PayGoodsUpdateReq {
// 购票id
int64 id = 1 [(gogoproto.jsontag) = "id"];
// 平台
string platform = 2 [(gogoproto.jsontag) = "platform"];
// 商品名称
string title = 3 [(gogoproto.jsontag) = "title"];
// 商品类型 2 付费直播门票
int64 type = 4 [(gogoproto.jsontag) = "type"];
// 商品价格(分)
int64 price = 5 [(gogoproto.jsontag) = "price"];
// 开始时间
string start_time = 6 [(gogoproto.jsontag) = "start_time"];
// 结束时间
string end_time = 7 [(gogoproto.jsontag) = "end_time"];
// ip限制0不限制1仅限大陆2仅限港澳台3大陆+港澳台
int64 ip_limit = 8 [(gogoproto.jsontag) = "ip_limit"];
}
message PayGoodsUpdateResp {
// 返回code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// 返回msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
// 返回data
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
}
}
message PayGoodsGetListReq {
// 购票id
int64 id = 1 [(gogoproto.jsontag) = "id"];
// 平台
string platform = 2 [(gogoproto.jsontag) = "platform"];
// 商品名称
string title = 3 [(gogoproto.jsontag) = "title"];
// 商品类型 2 付费直播门票
int64 type = 4 [(gogoproto.jsontag) = "type"];
// ip限制0不限制1仅限大陆2仅限港澳台3大陆+港澳台
int64 ip_limit = 5 [(gogoproto.jsontag) = "ip_limit"];
// 页号0开始
int64 page_num = 6 [(gogoproto.jsontag) = "page_num"];
// 每页个数
int64 page_size = 7 [(gogoproto.jsontag) = "page_size"];
}
message PayGoodsGetListResp {
// 返回code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// 返回msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
// 返回data
Data data = 3 [(gogoproto.jsontag) = "data"];
message PageInfo {
// 记录总数
int64 total_count = 1 [(gogoproto.jsontag) = "total_count"];
// 当前页号
int64 page_num = 2 [(gogoproto.jsontag) = "page_num"];
}
message GoodsInfo {
// 购票id
int64 id = 1 [(gogoproto.jsontag) = "id"];
// 标题
string title = 2 [(gogoproto.jsontag) = "title"];
// 平台
string platform = 3 [(gogoproto.jsontag) = "platform"];
// 类型2为付费直播
int64 type = 4 [(gogoproto.jsontag) = "type"];
// 价格,分
int64 price = 5 [(gogoproto.jsontag) = "price"];
// 开始购票时间
string start_time = 6 [(gogoproto.jsontag) = "start_time"];
// 结束购票时间
string end_time = 7 [(gogoproto.jsontag) = "end_time"];
// ip限制
int64 ip_limit = 8 [(gogoproto.jsontag) = "ip_limit"];
// 购票状态0关闭1购票中2未开始
int64 status = 9 [(gogoproto.jsontag) = "status"];
}
message Data {
//
PageInfo page_info = 1 [(gogoproto.jsontag) = "page_info"];
//
repeated GoodsInfo goods_info = 2 [(gogoproto.jsontag) = "goods_info"];
}
}
message PayGoodsCloseReq {
// 购票id
int64 id = 1 [(gogoproto.jsontag) = "id"];
}
message PayGoodsCloseResp {
// 返回code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// 返回msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
// 返回data
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
}
}
message PayGoodsOpenReq {
// 购票id
int64 id = 1 [(gogoproto.jsontag) = "id"];
}
message PayGoodsOpenResp {
// 返回code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// 返回msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
// 返回data
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
}
}

View File

@@ -0,0 +1,98 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v0/PayLive.proto
package v0
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
// =================
// PayLive Interface
// =================
type PayLive interface {
// * 生成付费直播信息
//
Add(context.Context, *PayLiveAddReq) (*PayLiveAddResp, error)
// * 更新付费直播信息
//
Update(context.Context, *PayLiveUpdateReq) (*PayLiveUpdateResp, error)
// * 获取付费直播列表
//
GetList(context.Context, *PayLiveGetListReq) (*PayLiveGetListResp, error)
// * 关闭鉴权
//
Close(context.Context, *PayLiveCloseReq) (*PayLiveCloseResp, error)
// * 开启鉴权
//
Open(context.Context, *PayLiveOpenReq) (*PayLiveOpenResp, error)
}
// =======================
// PayLive Live Rpc Client
// =======================
type payLiveRpcClient struct {
client *liverpc.Client
}
// NewPayLiveRpcClient creates a Rpc client that implements the PayLive interface.
// It communicates using Rpc and can be configured with a custom HTTPClient.
func NewPayLiveRpcClient(client *liverpc.Client) PayLive {
return &payLiveRpcClient{
client: client,
}
}
func (c *payLiveRpcClient) Add(ctx context.Context, in *PayLiveAddReq) (*PayLiveAddResp, error) {
out := new(PayLiveAddResp)
err := doRpcRequest(ctx, c.client, 0, "PayLive.add", in, out)
if err != nil {
return nil, err
}
return out, nil
}
func (c *payLiveRpcClient) Update(ctx context.Context, in *PayLiveUpdateReq) (*PayLiveUpdateResp, error) {
out := new(PayLiveUpdateResp)
err := doRpcRequest(ctx, c.client, 0, "PayLive.update", in, out)
if err != nil {
return nil, err
}
return out, nil
}
func (c *payLiveRpcClient) GetList(ctx context.Context, in *PayLiveGetListReq) (*PayLiveGetListResp, error) {
out := new(PayLiveGetListResp)
err := doRpcRequest(ctx, c.client, 0, "PayLive.getList", in, out)
if err != nil {
return nil, err
}
return out, nil
}
func (c *payLiveRpcClient) Close(ctx context.Context, in *PayLiveCloseReq) (*PayLiveCloseResp, error) {
out := new(PayLiveCloseResp)
err := doRpcRequest(ctx, c.client, 0, "PayLive.close", in, out)
if err != nil {
return nil, err
}
return out, nil
}
func (c *payLiveRpcClient) Open(ctx context.Context, in *PayLiveOpenReq) (*PayLiveOpenResp, error) {
out := new(PayLiveOpenResp)
err := doRpcRequest(ctx, c.client, 0, "PayLive.open", in, out)
if err != nil {
return nil, err
}
return out, nil
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,236 @@
syntax = "proto3";
package av.v0;
option go_package = "v0";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service PayLive {
/** 生成付费直播信息
*
*/
rpc add (PayLiveAddReq) returns (PayLiveAddResp);
/** 更新付费直播信息
*
*/
rpc update (PayLiveUpdateReq) returns (PayLiveUpdateResp);
/** 获取付费直播列表
*
*/
rpc getList (PayLiveGetListReq) returns (PayLiveGetListResp);
/** 关闭鉴权
*
*/
rpc close (PayLiveCloseReq) returns (PayLiveCloseResp);
/** 开启鉴权
*
*/
rpc open (PayLiveOpenReq) returns (PayLiveOpenResp);
}
message PayLiveAddReq {
// 平台
string platform = 1 [(gogoproto.jsontag) = "platform"];
// 商品名称
int64 room_id = 2 [(gogoproto.jsontag) = "room_id"];
// 商品名称
string title = 3 [(gogoproto.jsontag) = "title"];
// 鉴权状态1开0关
int64 status = 4 [(gogoproto.jsontag) = "status"];
// 开始时间
string start_time = 5 [(gogoproto.jsontag) = "start_time"];
// 结束时间
string end_time = 6 [(gogoproto.jsontag) = "end_time"];
// 正片结束时间
string live_end_time = 7 [(gogoproto.jsontag) = "live_end_time"];
// 正片保底图
string live_pic = 8 [(gogoproto.jsontag) = "live_pic"];
// 广告图
string ad_pic = 9 [(gogoproto.jsontag) = "ad_pic"];
// 购买链接
string goods_link = 10 [(gogoproto.jsontag) = "goods_link"];
// 门票id逗号分隔
string goods_id = 11 [(gogoproto.jsontag) = "goods_id"];
// 引导购票id
int64 buy_goods_id = 12 [(gogoproto.jsontag) = "buy_goods_id"];
// ip限制0不限制1仅限大陆2仅限港澳台3大陆+港澳台
int64 ip_limit = 13 [(gogoproto.jsontag) = "ip_limit"];
}
message PayLiveAddResp {
// 返回code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// 返回msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
// 返回data
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
}
}
message PayLiveUpdateReq {
// id
int64 live_id = 1 [(gogoproto.jsontag) = "live_id"];
// 平台
string platform = 2 [(gogoproto.jsontag) = "platform"];
// 商品名称
int64 room_id = 3 [(gogoproto.jsontag) = "room_id"];
// 商品名称
string title = 4 [(gogoproto.jsontag) = "title"];
// 鉴权状态1开0关
int64 status = 5 [(gogoproto.jsontag) = "status"];
// 开始时间
string start_time = 6 [(gogoproto.jsontag) = "start_time"];
// 结束时间
string end_time = 7 [(gogoproto.jsontag) = "end_time"];
// 正片结束时间
string live_end_time = 8 [(gogoproto.jsontag) = "live_end_time"];
// 正片保底图
string live_pic = 9 [(gogoproto.jsontag) = "live_pic"];
// 广告图
string ad_pic = 10 [(gogoproto.jsontag) = "ad_pic"];
// 购买链接
string goods_link = 11 [(gogoproto.jsontag) = "goods_link"];
// 门票id逗号分隔
string goods_id = 12 [(gogoproto.jsontag) = "goods_id"];
// 引导购票id
int64 buy_goods_id = 13 [(gogoproto.jsontag) = "buy_goods_id"];
// ip限制0不限制1仅限大陆2仅限港澳台3大陆+港澳台
int64 ip_limit = 14 [(gogoproto.jsontag) = "ip_limit"];
}
message PayLiveUpdateResp {
// 返回code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// 返回msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
// 返回data
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
}
}
message PayLiveGetListReq {
// 房间id
int64 room_id = 1 [(gogoproto.jsontag) = "room_id"];
// 商品名称
string title = 2 [(gogoproto.jsontag) = "title"];
// ip限制
int64 ip_limit = 3 [(gogoproto.jsontag) = "ip_limit"];
// 页号0开始
int64 page_num = 4 [(gogoproto.jsontag) = "page_num"];
// 每页个数
int64 page_size = 5 [(gogoproto.jsontag) = "page_size"];
}
message PayLiveGetListResp {
// 返回code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// 返回msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
// 返回data
Data data = 3 [(gogoproto.jsontag) = "data"];
message PageInfo {
// 记录总数
int64 total_count = 1 [(gogoproto.jsontag) = "total_count"];
// 当前页号
int64 page_num = 2 [(gogoproto.jsontag) = "page_num"];
}
message GoodsInfo {
// 房间id
int64 room_id = 1 [(gogoproto.jsontag) = "room_id"];
// 付费直播id
int64 live_id = 2 [(gogoproto.jsontag) = "live_id"];
// 标题
string title = 3 [(gogoproto.jsontag) = "title"];
// 平台
string platform = 4 [(gogoproto.jsontag) = "platform"];
// 生效状态1生效0未生效
int64 pay_live_status = 5 [(gogoproto.jsontag) = "pay_live_status"];
// 开始购票时间
string start_time = 6 [(gogoproto.jsontag) = "start_time"];
// 结束购票时间
string end_time = 7 [(gogoproto.jsontag) = "end_time"];
// 正片结束
string live_end_time = 8 [(gogoproto.jsontag) = "live_end_time"];
// 正片保底图
string live_pic = 9 [(gogoproto.jsontag) = "live_pic"];
// 广告图
string ad_pic = 10 [(gogoproto.jsontag) = "ad_pic"];
// 购票链接
string goods_link = 11 [(gogoproto.jsontag) = "goods_link"];
// 购票id
string goods_id = 12 [(gogoproto.jsontag) = "goods_id"];
// 引导购票id
int64 buy_goods_id = 13 [(gogoproto.jsontag) = "buy_goods_id"];
// ip限制
int64 ip_limit = 14 [(gogoproto.jsontag) = "ip_limit"];
// 鉴权状态0关闭1开启
int64 status = 15 [(gogoproto.jsontag) = "status"];
}
message Data {
//
PageInfo page_info = 1 [(gogoproto.jsontag) = "page_info"];
//
repeated GoodsInfo goods_info = 2 [(gogoproto.jsontag) = "goods_info"];
}
}
message PayLiveCloseReq {
// 直播id
int64 live_id = 1 [(gogoproto.jsontag) = "live_id"];
}
message PayLiveCloseResp {
// 返回code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// 返回msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
// 返回data
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
}
}
message PayLiveOpenReq {
// 直播id
int64 live_id = 1 [(gogoproto.jsontag) = "live_id"];
}
message PayLiveOpenResp {
// 返回code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// 返回msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
// 返回data
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
}
}

View File

@@ -0,0 +1,62 @@
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 = [
"PayLive.proto",
"Pk.proto",
],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "v1_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/service/live/av/api/liverpc/v1",
proto = ":v1_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = [
"PayLive.liverpc.go",
"Pk.liverpc.go",
],
embed = [":v1_go_proto"],
importpath = "go-common/app/service/live/av/api/liverpc/v1",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/liverpc:go_default_library",
"@com_github_gogo_protobuf//gogoproto: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,64 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v1/PayLive.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/PayLive.proto
v1/Pk.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:
// =================
// PayLive Interface
// =================
type PayLive interface {
// * 付费直播鉴权
//
LiveValidate(context.Context, *PayLiveLiveValidateReq) (*PayLiveLiveValidateResp, error)
}
// =======================
// PayLive Live Rpc Client
// =======================
type payLiveRpcClient struct {
client *liverpc.Client
}
// NewPayLiveRpcClient creates a Rpc client that implements the PayLive interface.
// It communicates using Rpc and can be configured with a custom HTTPClient.
func NewPayLiveRpcClient(client *liverpc.Client) PayLive {
return &payLiveRpcClient{
client: client,
}
}
func (c *payLiveRpcClient) LiveValidate(ctx context.Context, in *PayLiveLiveValidateReq) (*PayLiveLiveValidateResp, error) {
out := new(PayLiveLiveValidateResp)
err := doRpcRequest(ctx, c.client, 1, "PayLive.liveValidate", in, out)
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) (err error) {
err = client.Call(ctx, version, method, in, out)
return
}

View File

@@ -0,0 +1,780 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: v1/PayLive.proto
package v1
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type PayLiveLiveValidateReq struct {
// 房间id
RoomId int64 `protobuf:"varint,1,opt,name=room_id,json=roomId,proto3" json:"room_id"`
// 来源pc表示PC端pc_link表示PC直播姬ios表示ios端ios_link表示ios_link端android安卓端android_link安卓link端ipadipadandroid_pad:安卓pad端live_mng表示live后台;vc_mng表示vc后台;"
Platform string `protobuf:"bytes,2,opt,name=platform,proto3" json:"platform"`
}
func (m *PayLiveLiveValidateReq) Reset() { *m = PayLiveLiveValidateReq{} }
func (m *PayLiveLiveValidateReq) String() string { return proto.CompactTextString(m) }
func (*PayLiveLiveValidateReq) ProtoMessage() {}
func (*PayLiveLiveValidateReq) Descriptor() ([]byte, []int) {
return fileDescriptor_PayLive_366356d2c332491f, []int{0}
}
func (m *PayLiveLiveValidateReq) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *PayLiveLiveValidateReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_PayLiveLiveValidateReq.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *PayLiveLiveValidateReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_PayLiveLiveValidateReq.Merge(dst, src)
}
func (m *PayLiveLiveValidateReq) XXX_Size() int {
return m.Size()
}
func (m *PayLiveLiveValidateReq) XXX_DiscardUnknown() {
xxx_messageInfo_PayLiveLiveValidateReq.DiscardUnknown(m)
}
var xxx_messageInfo_PayLiveLiveValidateReq proto.InternalMessageInfo
func (m *PayLiveLiveValidateReq) GetRoomId() int64 {
if m != nil {
return m.RoomId
}
return 0
}
func (m *PayLiveLiveValidateReq) GetPlatform() string {
if m != nil {
return m.Platform
}
return ""
}
type PayLiveLiveValidateResp struct {
//
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code"`
//
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"`
//
Data *PayLiveLiveValidateResp_Data `protobuf:"bytes,3,opt,name=data" json:"data"`
}
func (m *PayLiveLiveValidateResp) Reset() { *m = PayLiveLiveValidateResp{} }
func (m *PayLiveLiveValidateResp) String() string { return proto.CompactTextString(m) }
func (*PayLiveLiveValidateResp) ProtoMessage() {}
func (*PayLiveLiveValidateResp) Descriptor() ([]byte, []int) {
return fileDescriptor_PayLive_366356d2c332491f, []int{1}
}
func (m *PayLiveLiveValidateResp) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *PayLiveLiveValidateResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_PayLiveLiveValidateResp.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *PayLiveLiveValidateResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_PayLiveLiveValidateResp.Merge(dst, src)
}
func (m *PayLiveLiveValidateResp) XXX_Size() int {
return m.Size()
}
func (m *PayLiveLiveValidateResp) XXX_DiscardUnknown() {
xxx_messageInfo_PayLiveLiveValidateResp.DiscardUnknown(m)
}
var xxx_messageInfo_PayLiveLiveValidateResp proto.InternalMessageInfo
func (m *PayLiveLiveValidateResp) GetCode() int64 {
if m != nil {
return m.Code
}
return 0
}
func (m *PayLiveLiveValidateResp) GetMsg() string {
if m != nil {
return m.Msg
}
return ""
}
func (m *PayLiveLiveValidateResp) GetData() *PayLiveLiveValidateResp_Data {
if m != nil {
return m.Data
}
return nil
}
type PayLiveLiveValidateResp_Data struct {
// 1 允许 ; 0 不允许
Permission int64 `protobuf:"varint,1,opt,name=permission,proto3" json:"permission"`
}
func (m *PayLiveLiveValidateResp_Data) Reset() { *m = PayLiveLiveValidateResp_Data{} }
func (m *PayLiveLiveValidateResp_Data) String() string { return proto.CompactTextString(m) }
func (*PayLiveLiveValidateResp_Data) ProtoMessage() {}
func (*PayLiveLiveValidateResp_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_PayLive_366356d2c332491f, []int{1, 0}
}
func (m *PayLiveLiveValidateResp_Data) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *PayLiveLiveValidateResp_Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_PayLiveLiveValidateResp_Data.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *PayLiveLiveValidateResp_Data) XXX_Merge(src proto.Message) {
xxx_messageInfo_PayLiveLiveValidateResp_Data.Merge(dst, src)
}
func (m *PayLiveLiveValidateResp_Data) XXX_Size() int {
return m.Size()
}
func (m *PayLiveLiveValidateResp_Data) XXX_DiscardUnknown() {
xxx_messageInfo_PayLiveLiveValidateResp_Data.DiscardUnknown(m)
}
var xxx_messageInfo_PayLiveLiveValidateResp_Data proto.InternalMessageInfo
func (m *PayLiveLiveValidateResp_Data) GetPermission() int64 {
if m != nil {
return m.Permission
}
return 0
}
func init() {
proto.RegisterType((*PayLiveLiveValidateReq)(nil), "av.v1.PayLiveLiveValidateReq")
proto.RegisterType((*PayLiveLiveValidateResp)(nil), "av.v1.PayLiveLiveValidateResp")
proto.RegisterType((*PayLiveLiveValidateResp_Data)(nil), "av.v1.PayLiveLiveValidateResp.Data")
}
func (m *PayLiveLiveValidateReq) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *PayLiveLiveValidateReq) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.RoomId != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintPayLive(dAtA, i, uint64(m.RoomId))
}
if len(m.Platform) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintPayLive(dAtA, i, uint64(len(m.Platform)))
i += copy(dAtA[i:], m.Platform)
}
return i, nil
}
func (m *PayLiveLiveValidateResp) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *PayLiveLiveValidateResp) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Code != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintPayLive(dAtA, i, uint64(m.Code))
}
if len(m.Msg) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintPayLive(dAtA, i, uint64(len(m.Msg)))
i += copy(dAtA[i:], m.Msg)
}
if m.Data != nil {
dAtA[i] = 0x1a
i++
i = encodeVarintPayLive(dAtA, i, uint64(m.Data.Size()))
n1, err := m.Data.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n1
}
return i, nil
}
func (m *PayLiveLiveValidateResp_Data) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *PayLiveLiveValidateResp_Data) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Permission != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintPayLive(dAtA, i, uint64(m.Permission))
}
return i, nil
}
func encodeVarintPayLive(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *PayLiveLiveValidateReq) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.RoomId != 0 {
n += 1 + sovPayLive(uint64(m.RoomId))
}
l = len(m.Platform)
if l > 0 {
n += 1 + l + sovPayLive(uint64(l))
}
return n
}
func (m *PayLiveLiveValidateResp) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Code != 0 {
n += 1 + sovPayLive(uint64(m.Code))
}
l = len(m.Msg)
if l > 0 {
n += 1 + l + sovPayLive(uint64(l))
}
if m.Data != nil {
l = m.Data.Size()
n += 1 + l + sovPayLive(uint64(l))
}
return n
}
func (m *PayLiveLiveValidateResp_Data) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Permission != 0 {
n += 1 + sovPayLive(uint64(m.Permission))
}
return n
}
func sovPayLive(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozPayLive(x uint64) (n int) {
return sovPayLive(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *PayLiveLiveValidateReq) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPayLive
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: PayLiveLiveValidateReq: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: PayLiveLiveValidateReq: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field RoomId", wireType)
}
m.RoomId = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPayLive
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.RoomId |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Platform", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPayLive
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthPayLive
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Platform = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipPayLive(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthPayLive
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *PayLiveLiveValidateResp) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPayLive
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: PayLiveLiveValidateResp: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: PayLiveLiveValidateResp: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
}
m.Code = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPayLive
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Code |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPayLive
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthPayLive
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Msg = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPayLive
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthPayLive
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Data == nil {
m.Data = &PayLiveLiveValidateResp_Data{}
}
if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipPayLive(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthPayLive
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *PayLiveLiveValidateResp_Data) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPayLive
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Data: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Data: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Permission", wireType)
}
m.Permission = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowPayLive
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Permission |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipPayLive(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthPayLive
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipPayLive(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowPayLive
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowPayLive
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowPayLive
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthPayLive
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowPayLive
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipPayLive(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthPayLive = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowPayLive = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("v1/PayLive.proto", fileDescriptor_PayLive_366356d2c332491f) }
var fileDescriptor_PayLive_366356d2c332491f = []byte{
// 327 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0x41, 0x4b, 0x02, 0x41,
0x18, 0x75, 0xd4, 0xd4, 0x3e, 0x25, 0x62, 0x0e, 0x65, 0x62, 0xb3, 0x62, 0x1d, 0xf6, 0xd2, 0x88,
0x06, 0xdd, 0x93, 0x2e, 0x41, 0x41, 0xcc, 0x21, 0xa2, 0x4b, 0x8c, 0xee, 0xba, 0x0e, 0xb8, 0xcd,
0xba, 0x3b, 0x2e, 0xf4, 0x2f, 0xfa, 0x59, 0x5d, 0x02, 0x8f, 0x9d, 0x96, 0xd0, 0xdb, 0xfe, 0x8a,
0x98, 0x71, 0x93, 0x3d, 0x94, 0x87, 0xf9, 0x78, 0xef, 0x0d, 0xdf, 0x7b, 0x8f, 0x19, 0x38, 0x8c,
0xfb, 0xbd, 0x07, 0xfe, 0x76, 0x27, 0x62, 0x97, 0x06, 0xa1, 0x54, 0x12, 0xef, 0xf1, 0x98, 0xc6,
0xfd, 0xd6, 0x85, 0x27, 0xd4, 0x74, 0x31, 0xa2, 0x63, 0xe9, 0xf7, 0x3c, 0xe9, 0xc9, 0x9e, 0xb9,
0x1d, 0x2d, 0x26, 0x86, 0x19, 0x62, 0xd0, 0x66, 0xab, 0x3b, 0x85, 0xa3, 0xcc, 0x46, 0x9f, 0x47,
0x3e, 0x13, 0x0e, 0x57, 0x2e, 0x73, 0xe7, 0xf8, 0x1c, 0xaa, 0xa1, 0x94, 0xfe, 0x8b, 0x70, 0x9a,
0xa8, 0x83, 0xec, 0xd2, 0xb0, 0x9e, 0x26, 0xd6, 0xaf, 0xc4, 0x2a, 0x1a, 0xdc, 0x3a, 0xd8, 0x86,
0x5a, 0x30, 0xe3, 0x6a, 0x22, 0x43, 0xbf, 0x59, 0xec, 0x20, 0x7b, 0x7f, 0xd8, 0x48, 0x13, 0x6b,
0xab, 0xb1, 0x2d, 0xea, 0x7e, 0x22, 0x38, 0xfe, 0x33, 0x2a, 0x0a, 0x70, 0x1b, 0xca, 0x63, 0xe9,
0xb8, 0x59, 0x50, 0x2d, 0x4d, 0x2c, 0xc3, 0x99, 0x99, 0xf8, 0x04, 0x4a, 0x7e, 0xe4, 0x65, 0xf6,
0xd5, 0x34, 0xb1, 0x34, 0x65, 0x7a, 0xe0, 0x6b, 0x28, 0x3b, 0x5c, 0xf1, 0x66, 0xa9, 0x83, 0xec,
0xfa, 0xe0, 0x8c, 0x9a, 0x37, 0xa0, 0xff, 0xc4, 0xd0, 0x1b, 0xae, 0xf8, 0xc6, 0x5d, 0x2f, 0x31,
0x33, 0x5b, 0x57, 0x50, 0xd6, 0x3a, 0xa6, 0x00, 0x81, 0x1b, 0xfa, 0x22, 0x8a, 0x84, 0x7c, 0xcd,
0x9a, 0x1c, 0xa4, 0x89, 0x95, 0x53, 0x59, 0x0e, 0x0f, 0x9e, 0xa0, 0x9a, 0xe5, 0xe0, 0x7b, 0x68,
0xcc, 0x72, 0x59, 0xf8, 0x74, 0x57, 0x8f, 0x79, 0x8b, 0xec, 0xae, 0x39, 0x6c, 0x7f, 0xac, 0x08,
0x5a, 0xae, 0x08, 0xfa, 0x5e, 0x11, 0xf4, 0xbe, 0x26, 0x85, 0xe5, 0x9a, 0x14, 0xbe, 0xd6, 0xa4,
0xf0, 0x5c, 0x8c, 0xfb, 0xa3, 0x8a, 0xf9, 0xb8, 0xcb, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf6,
0xd8, 0x2e, 0x24, 0x02, 0x02, 0x00, 0x00,
}

View File

@@ -0,0 +1,38 @@
syntax = "proto3";
package av.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service PayLive {
/** 付费直播鉴权
*
*/
rpc liveValidate (PayLiveLiveValidateReq) returns (PayLiveLiveValidateResp);
}
message PayLiveLiveValidateReq {
// 房间id
int64 room_id = 1 [(gogoproto.jsontag) = "room_id"];
// 来源pc表示PC端pc_link表示PC直播姬ios表示ios端ios_link表示ios_link端android安卓端android_link安卓link端ipadipadandroid_pad:安卓pad端live_mng表示live后台;vc_mng表示vc后台;"
string platform = 2 [(gogoproto.jsontag) = "platform"];
}
message PayLiveLiveValidateResp {
//
int64 code = 1 [(gogoproto.jsontag) = "code"];
//
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
// 1 允许 ; 0 不允许
int64 permission = 1 [(gogoproto.jsontag) = "permission"];
}
}

View File

@@ -0,0 +1,72 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v1/Pk.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
// ============
// Pk Interface
// ============
type Pk interface {
// * 根据id获取PK基础信息
//
GetInfoById(context.Context, *PkGetInfoByIdReq) (*PkGetInfoByIdResp, error)
// * 根据id获取PK基础信息
//
GetPkStatus(context.Context, *PkGetPkStatusReq) (*PkGetPkStatusResp, error)
// * 批量获取pkIds
//
GetPkIdsByRoomIds(context.Context, *PkGetPkIdsByRoomIdsReq) (*PkGetPkIdsByRoomIdsResp, error)
}
// ==================
// Pk Live Rpc Client
// ==================
type pkRpcClient struct {
client *liverpc.Client
}
// NewPkRpcClient creates a Rpc client that implements the Pk interface.
// It communicates using Rpc and can be configured with a custom HTTPClient.
func NewPkRpcClient(client *liverpc.Client) Pk {
return &pkRpcClient{
client: client,
}
}
func (c *pkRpcClient) GetInfoById(ctx context.Context, in *PkGetInfoByIdReq) (*PkGetInfoByIdResp, error) {
out := new(PkGetInfoByIdResp)
err := doRpcRequest(ctx, c.client, 1, "Pk.getInfoById", in, out)
if err != nil {
return nil, err
}
return out, nil
}
func (c *pkRpcClient) GetPkStatus(ctx context.Context, in *PkGetPkStatusReq) (*PkGetPkStatusResp, error) {
out := new(PkGetPkStatusResp)
err := doRpcRequest(ctx, c.client, 1, "Pk.getPkStatus", in, out)
if err != nil {
return nil, err
}
return out, nil
}
func (c *pkRpcClient) GetPkIdsByRoomIds(ctx context.Context, in *PkGetPkIdsByRoomIdsReq) (*PkGetPkIdsByRoomIdsResp, error) {
out := new(PkGetPkIdsByRoomIdsResp)
err := doRpcRequest(ctx, c.client, 1, "Pk.getPkIdsByRoomIds", in, out)
if err != nil {
return nil, err
}
return out, nil
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,119 @@
syntax = "proto3";
package av.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service Pk {
/** 根据id获取PK基础信息
*
*/
rpc getInfoById (PkGetInfoByIdReq) returns (PkGetInfoByIdResp);
/** 根据id获取PK基础信息
*
*/
rpc getPkStatus (PkGetPkStatusReq) returns (PkGetPkStatusResp);
/** 批量获取pkIds
*
*/
rpc getPkIdsByRoomIds (PkGetPkIdsByRoomIdsReq) returns (PkGetPkIdsByRoomIdsResp);
}
message PkGetInfoByIdReq {
// 会返回主播数据
int64 is_anchor = 1 [(gogoproto.jsontag) = "is_anchor"];
// 直播场次id
int64 pk_id = 2 [(gogoproto.jsontag) = "pk_id"];
// 房间id 房间id pk_id与room_id必传一个
int64 room_id = 3 [(gogoproto.jsontag) = "room_id"];
// 来源pc表示PC端pc_link表示PC直播姬ios表示ios端ios_link表示ios_link端android安卓端android_link安卓link端ipadipadandroid_pad:安卓pad端live_mng表示live后台;vc_mng表示vc后台;"
string platform = 4 [(gogoproto.jsontag) = "platform"];
}
message PkGetInfoByIdResp {
//
int64 code = 1 [(gogoproto.jsontag) = "code"];
//
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
// 本场直播pk_id
int64 pk_id = 1 [(gogoproto.jsontag) = "pk_id"];
// 发起方房间id
int64 init_id = 2 [(gogoproto.jsontag) = "init_id"];
// 匹配方房间id
int64 match_id = 3 [(gogoproto.jsontag) = "match_id"];
// pk预备发起时间
int64 pre_time = 4 [(gogoproto.jsontag) = "pre_time"];
// pk状态 0 匹配成功;1.pk准备中; 2.pk进行中; 3.惩罚中; 10.连麦正常结束; 11.pk中断,连麦结束, 12 连麦异常,连麦结束
int64 status = 5 [(gogoproto.jsontag) = "status"];
// pk话题
string pk_topic = 6 [(gogoproto.jsontag) = "pk_topic"];
// 惩罚话题
string punish_topic = 7 [(gogoproto.jsontag) = "punish_topic"];
}
}
message PkGetPkStatusReq {
// 会返回主播数据
int64 is_anchor = 1 [(gogoproto.jsontag) = "is_anchor"];
// 直播场次id
int64 pk_id = 2 [(gogoproto.jsontag) = "pk_id"];
// 房间id 房间id pk_id与room_id必传一个
int64 room_id = 3 [(gogoproto.jsontag) = "room_id"];
// 邀请id
int64 invite_id = 4 [(gogoproto.jsontag) = "invite_id"];
// 来源pc表示PC端pc_link表示PC直播姬ios表示ios端ios_link表示ios_link端android安卓端android_link安卓link端ipadipadandroid_pad:安卓pad端live_mng表示live后台;vc_mng表示vc后台;"
string platform = 5 [(gogoproto.jsontag) = "platform"];
}
message PkGetPkStatusResp {
//
int64 code = 1 [(gogoproto.jsontag) = "code"];
//
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
// 当前时间
int64 timestamp = 1 [(gogoproto.jsontag) = "timestamp"];
// 本场直播pk_id
int64 pk_id = 2 [(gogoproto.jsontag) = "pk_id"];
// pk状态 100 匹配成功;200.pk准备中; 300.pk进行中; 400惩罚中; 1000.连麦正常结束; 1100.pk中断,连麦结束, 1200逃跑 1300 连麦异常,连麦结束
int64 pk_status = 3 [(gogoproto.jsontag) = "pk_status"];
// 邀请id
int64 invite_id = 4 [(gogoproto.jsontag) = "invite_id"];
// 100 排队中 200 邀请中 1000 同意邀请 1100 拒绝邀请 1200 取消邀请,1300 邀请异常(主播信息)
int64 invite_status = 5 [(gogoproto.jsontag) = "invite_status"];
}
}
message PkGetPkIdsByRoomIdsReq {
// 房间ids
repeated int64 room_ids = 1 [(gogoproto.jsontag) = "room_ids"];
// 来源pc表示PC端pc_link表示PC直播姬ios表示ios端ios_link表示ios_link端android安卓端android_link安卓link端ipadipadandroid_pad:安卓pad端live_mng表示live后台;vc_mng表示vc后台;"
string platform = 2 [(gogoproto.jsontag) = "platform"];
}
message PkGetPkIdsByRoomIdsResp {
//
int64 code = 1 [(gogoproto.jsontag) = "code"];
//
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
map<string, int64> data = 3 [(gogoproto.jsontag) = "data"];
}

View File

@@ -0,0 +1,16 @@
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/banned_service/api/liverpc:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,35 @@
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/app/service/live/banned_service/api/liverpc",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/live/banned_service/api/liverpc/v1:go_default_library",
"//library/net/rpc/liverpc:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/banned_service/api/liverpc/v1:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,57 @@
// 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 liverpc
import (
"go-common/app/service/live/banned_service/api/liverpc/v1"
"go-common/library/net/rpc/liverpc"
)
// Client that represents a liverpc banned_service service api
type Client struct {
cli *liverpc.Client
// V1AdminSilent presents the controller in liverpc
V1AdminSilent v1.AdminSilent
// V1Shield presents the controller in liverpc
V1Shield v1.Shield
// V1ShieldMng presents the controller in liverpc
V1ShieldMng v1.ShieldMng
// V1Silent presents the controller in liverpc
V1Silent v1.Silent
// V1SilentMng presents the controller in liverpc
V1SilentMng v1.SilentMng
// V1SiteBlockMng presents the controller in liverpc
V1SiteBlockMng v1.SiteBlockMng
}
// DiscoveryAppId the discovery id is not the tree name
var DiscoveryAppId = "live.bannedservice"
// New a Client that represents a liverpc live.bannedservice 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.V1AdminSilent = v1.NewAdminSilentRpcClient(realCli)
cli.V1Shield = v1.NewShieldRpcClient(realCli)
cli.V1ShieldMng = v1.NewShieldMngRpcClient(realCli)
cli.V1Silent = v1.NewSilentRpcClient(realCli)
cli.V1SilentMng = v1.NewSilentMngRpcClient(realCli)
cli.V1SiteBlockMng = v1.NewSiteBlockMngRpcClient(realCli)
}

View File

@@ -0,0 +1,68 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v1/AdminSilent.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/AdminSilent.proto
v1/Shield.proto
v1/ShieldMng.proto
v1/Silent.proto
v1/SilentMng.proto
v1/SiteBlockMng.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:
// =====================
// AdminSilent Interface
// =====================
type AdminSilent interface {
// * 查询运营规则
// 拿着规则直接用就好了,有就肯定是当前生效的配置
GetShieldRule(context.Context, *AdminSilentGetShieldRuleReq) (*AdminSilentGetShieldRuleResp, error)
}
// ===========================
// AdminSilent Live Rpc Client
// ===========================
type adminSilentRpcClient struct {
client *liverpc.Client
}
// NewAdminSilentRpcClient creates a Rpc client that implements the AdminSilent interface.
// It communicates using Rpc and can be configured with a custom HTTPClient.
func NewAdminSilentRpcClient(client *liverpc.Client) AdminSilent {
return &adminSilentRpcClient{
client: client,
}
}
func (c *adminSilentRpcClient) GetShieldRule(ctx context.Context, in *AdminSilentGetShieldRuleReq) (*AdminSilentGetShieldRuleResp, error) {
out := new(AdminSilentGetShieldRuleResp)
err := doRpcRequest(ctx, c.client, 1, "AdminSilent.get_shield_rule", in, out)
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) (err error) {
err = client.Call(ctx, version, method, in, out)
return
}

View File

@@ -0,0 +1,843 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: v1/AdminSilent.proto
package v1
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type AdminSilentGetShieldRuleReq struct {
//
Roomid int64 `protobuf:"varint,1,opt,name=roomid,proto3" json:"roomid"`
}
func (m *AdminSilentGetShieldRuleReq) Reset() { *m = AdminSilentGetShieldRuleReq{} }
func (m *AdminSilentGetShieldRuleReq) String() string { return proto.CompactTextString(m) }
func (*AdminSilentGetShieldRuleReq) ProtoMessage() {}
func (*AdminSilentGetShieldRuleReq) Descriptor() ([]byte, []int) {
return fileDescriptor_AdminSilent_417b426140a13835, []int{0}
}
func (m *AdminSilentGetShieldRuleReq) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *AdminSilentGetShieldRuleReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_AdminSilentGetShieldRuleReq.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *AdminSilentGetShieldRuleReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_AdminSilentGetShieldRuleReq.Merge(dst, src)
}
func (m *AdminSilentGetShieldRuleReq) XXX_Size() int {
return m.Size()
}
func (m *AdminSilentGetShieldRuleReq) XXX_DiscardUnknown() {
xxx_messageInfo_AdminSilentGetShieldRuleReq.DiscardUnknown(m)
}
var xxx_messageInfo_AdminSilentGetShieldRuleReq proto.InternalMessageInfo
func (m *AdminSilentGetShieldRuleReq) GetRoomid() int64 {
if m != nil {
return m.Roomid
}
return 0
}
type AdminSilentGetShieldRuleResp struct {
//
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code"`
//
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"`
//
Data *AdminSilentGetShieldRuleResp_Data `protobuf:"bytes,3,opt,name=data" json:"data"`
}
func (m *AdminSilentGetShieldRuleResp) Reset() { *m = AdminSilentGetShieldRuleResp{} }
func (m *AdminSilentGetShieldRuleResp) String() string { return proto.CompactTextString(m) }
func (*AdminSilentGetShieldRuleResp) ProtoMessage() {}
func (*AdminSilentGetShieldRuleResp) Descriptor() ([]byte, []int) {
return fileDescriptor_AdminSilent_417b426140a13835, []int{1}
}
func (m *AdminSilentGetShieldRuleResp) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *AdminSilentGetShieldRuleResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_AdminSilentGetShieldRuleResp.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *AdminSilentGetShieldRuleResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_AdminSilentGetShieldRuleResp.Merge(dst, src)
}
func (m *AdminSilentGetShieldRuleResp) XXX_Size() int {
return m.Size()
}
func (m *AdminSilentGetShieldRuleResp) XXX_DiscardUnknown() {
xxx_messageInfo_AdminSilentGetShieldRuleResp.DiscardUnknown(m)
}
var xxx_messageInfo_AdminSilentGetShieldRuleResp proto.InternalMessageInfo
func (m *AdminSilentGetShieldRuleResp) GetCode() int64 {
if m != nil {
return m.Code
}
return 0
}
func (m *AdminSilentGetShieldRuleResp) GetMsg() string {
if m != nil {
return m.Msg
}
return ""
}
func (m *AdminSilentGetShieldRuleResp) GetData() *AdminSilentGetShieldRuleResp_Data {
if m != nil {
return m.Data
}
return nil
}
type AdminSilentGetShieldRuleResp_Data struct {
//
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id"`
// 为0表示全局规则
Roomid int64 `protobuf:"varint,2,opt,name=roomid,proto3" json:"roomid"`
// 房间真实分要求
RealScore int64 `protobuf:"varint,3,opt,name=real_score,json=realScore,proto3" json:"real_score"`
// 范围0~10, 乘以了10
AiScore int64 `protobuf:"varint,4,opt,name=ai_score,json=aiScore,proto3" json:"ai_score"`
}
func (m *AdminSilentGetShieldRuleResp_Data) Reset() { *m = AdminSilentGetShieldRuleResp_Data{} }
func (m *AdminSilentGetShieldRuleResp_Data) String() string { return proto.CompactTextString(m) }
func (*AdminSilentGetShieldRuleResp_Data) ProtoMessage() {}
func (*AdminSilentGetShieldRuleResp_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_AdminSilent_417b426140a13835, []int{1, 0}
}
func (m *AdminSilentGetShieldRuleResp_Data) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *AdminSilentGetShieldRuleResp_Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_AdminSilentGetShieldRuleResp_Data.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *AdminSilentGetShieldRuleResp_Data) XXX_Merge(src proto.Message) {
xxx_messageInfo_AdminSilentGetShieldRuleResp_Data.Merge(dst, src)
}
func (m *AdminSilentGetShieldRuleResp_Data) XXX_Size() int {
return m.Size()
}
func (m *AdminSilentGetShieldRuleResp_Data) XXX_DiscardUnknown() {
xxx_messageInfo_AdminSilentGetShieldRuleResp_Data.DiscardUnknown(m)
}
var xxx_messageInfo_AdminSilentGetShieldRuleResp_Data proto.InternalMessageInfo
func (m *AdminSilentGetShieldRuleResp_Data) GetId() int64 {
if m != nil {
return m.Id
}
return 0
}
func (m *AdminSilentGetShieldRuleResp_Data) GetRoomid() int64 {
if m != nil {
return m.Roomid
}
return 0
}
func (m *AdminSilentGetShieldRuleResp_Data) GetRealScore() int64 {
if m != nil {
return m.RealScore
}
return 0
}
func (m *AdminSilentGetShieldRuleResp_Data) GetAiScore() int64 {
if m != nil {
return m.AiScore
}
return 0
}
func init() {
proto.RegisterType((*AdminSilentGetShieldRuleReq)(nil), "banned_service.v1.AdminSilentGetShieldRuleReq")
proto.RegisterType((*AdminSilentGetShieldRuleResp)(nil), "banned_service.v1.AdminSilentGetShieldRuleResp")
proto.RegisterType((*AdminSilentGetShieldRuleResp_Data)(nil), "banned_service.v1.AdminSilentGetShieldRuleResp.Data")
}
func (m *AdminSilentGetShieldRuleReq) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *AdminSilentGetShieldRuleReq) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Roomid != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintAdminSilent(dAtA, i, uint64(m.Roomid))
}
return i, nil
}
func (m *AdminSilentGetShieldRuleResp) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *AdminSilentGetShieldRuleResp) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Code != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintAdminSilent(dAtA, i, uint64(m.Code))
}
if len(m.Msg) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintAdminSilent(dAtA, i, uint64(len(m.Msg)))
i += copy(dAtA[i:], m.Msg)
}
if m.Data != nil {
dAtA[i] = 0x1a
i++
i = encodeVarintAdminSilent(dAtA, i, uint64(m.Data.Size()))
n1, err := m.Data.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n1
}
return i, nil
}
func (m *AdminSilentGetShieldRuleResp_Data) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *AdminSilentGetShieldRuleResp_Data) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Id != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintAdminSilent(dAtA, i, uint64(m.Id))
}
if m.Roomid != 0 {
dAtA[i] = 0x10
i++
i = encodeVarintAdminSilent(dAtA, i, uint64(m.Roomid))
}
if m.RealScore != 0 {
dAtA[i] = 0x18
i++
i = encodeVarintAdminSilent(dAtA, i, uint64(m.RealScore))
}
if m.AiScore != 0 {
dAtA[i] = 0x20
i++
i = encodeVarintAdminSilent(dAtA, i, uint64(m.AiScore))
}
return i, nil
}
func encodeVarintAdminSilent(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *AdminSilentGetShieldRuleReq) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Roomid != 0 {
n += 1 + sovAdminSilent(uint64(m.Roomid))
}
return n
}
func (m *AdminSilentGetShieldRuleResp) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Code != 0 {
n += 1 + sovAdminSilent(uint64(m.Code))
}
l = len(m.Msg)
if l > 0 {
n += 1 + l + sovAdminSilent(uint64(l))
}
if m.Data != nil {
l = m.Data.Size()
n += 1 + l + sovAdminSilent(uint64(l))
}
return n
}
func (m *AdminSilentGetShieldRuleResp_Data) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Id != 0 {
n += 1 + sovAdminSilent(uint64(m.Id))
}
if m.Roomid != 0 {
n += 1 + sovAdminSilent(uint64(m.Roomid))
}
if m.RealScore != 0 {
n += 1 + sovAdminSilent(uint64(m.RealScore))
}
if m.AiScore != 0 {
n += 1 + sovAdminSilent(uint64(m.AiScore))
}
return n
}
func sovAdminSilent(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozAdminSilent(x uint64) (n int) {
return sovAdminSilent(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *AdminSilentGetShieldRuleReq) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: AdminSilentGetShieldRuleReq: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: AdminSilentGetShieldRuleReq: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Roomid", wireType)
}
m.Roomid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Roomid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipAdminSilent(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthAdminSilent
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *AdminSilentGetShieldRuleResp) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: AdminSilentGetShieldRuleResp: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: AdminSilentGetShieldRuleResp: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
}
m.Code = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Code |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthAdminSilent
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Msg = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthAdminSilent
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Data == nil {
m.Data = &AdminSilentGetShieldRuleResp_Data{}
}
if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipAdminSilent(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthAdminSilent
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *AdminSilentGetShieldRuleResp_Data) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Data: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Data: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType)
}
m.Id = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Id |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Roomid", wireType)
}
m.Roomid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Roomid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field RealScore", wireType)
}
m.RealScore = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.RealScore |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field AiScore", wireType)
}
m.AiScore = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.AiScore |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipAdminSilent(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthAdminSilent
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipAdminSilent(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthAdminSilent
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowAdminSilent
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipAdminSilent(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthAdminSilent = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowAdminSilent = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("v1/AdminSilent.proto", fileDescriptor_AdminSilent_417b426140a13835) }
var fileDescriptor_AdminSilent_417b426140a13835 = []byte{
// 371 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0xbd, 0x6a, 0xeb, 0x30,
0x18, 0x8d, 0x6c, 0x93, 0x1f, 0xe5, 0x72, 0x2f, 0x57, 0x5c, 0x2e, 0x69, 0x1a, 0xec, 0x90, 0xa5,
0x59, 0x62, 0x93, 0xb4, 0x2f, 0x10, 0x53, 0xe8, 0xae, 0x6c, 0x5d, 0x8c, 0x6c, 0xa9, 0x8e, 0xc0,
0xb6, 0x12, 0xff, 0xed, 0x7d, 0x83, 0xce, 0x7d, 0xa2, 0x8c, 0x19, 0x3b, 0x99, 0x92, 0x6c, 0x7e,
0x8a, 0x62, 0xc5, 0x04, 0x43, 0x49, 0x21, 0xcb, 0xa7, 0xef, 0x1c, 0x1d, 0xce, 0xa7, 0xf3, 0x21,
0xf8, 0x2f, 0x9f, 0x5b, 0x4b, 0x1a, 0xf2, 0x68, 0xc5, 0x03, 0x16, 0xa5, 0xe6, 0x26, 0x16, 0xa9,
0x40, 0x7f, 0x5d, 0x12, 0x45, 0x8c, 0x3a, 0x09, 0x8b, 0x73, 0xee, 0x31, 0x33, 0x9f, 0x0f, 0x67,
0x3e, 0x4f, 0xd7, 0x99, 0x6b, 0x7a, 0x22, 0xb4, 0x7c, 0xe1, 0x0b, 0x4b, 0x2a, 0xdd, 0xec, 0x45,
0x22, 0x09, 0x64, 0x77, 0x72, 0x98, 0x2c, 0xe1, 0x6d, 0xc3, 0xf6, 0x89, 0xa5, 0xab, 0x35, 0x67,
0x01, 0xc5, 0x59, 0xc0, 0x30, 0xdb, 0xa2, 0x09, 0x6c, 0xc7, 0x42, 0x84, 0x9c, 0x0e, 0xc0, 0x18,
0x4c, 0x55, 0x1b, 0x96, 0x85, 0x51, 0x33, 0xb8, 0x3e, 0x27, 0x3b, 0x05, 0x8e, 0x2e, 0x7b, 0x24,
0x1b, 0x34, 0x82, 0x9a, 0x27, 0x28, 0xab, 0x2d, 0xba, 0x65, 0x61, 0x48, 0x8c, 0x65, 0x45, 0x37,
0x50, 0x0d, 0x13, 0x7f, 0xa0, 0x8c, 0xc1, 0xb4, 0x67, 0x77, 0xca, 0xc2, 0xa8, 0x20, 0xae, 0x0a,
0xc2, 0x50, 0xa3, 0x24, 0x25, 0x03, 0x75, 0x0c, 0xa6, 0xfd, 0xc5, 0x83, 0xf9, 0x2d, 0xad, 0xf9,
0xd3, 0x5c, 0xf3, 0x91, 0xa4, 0xe4, 0x34, 0xae, 0x72, 0xc1, 0xb2, 0x0e, 0xdf, 0x01, 0xd4, 0xaa,
0x0b, 0xf4, 0x1f, 0x2a, 0xe7, 0x58, 0xed, 0xb2, 0x30, 0x14, 0x4e, 0xb1, 0xc2, 0x69, 0x23, 0xb2,
0x72, 0x29, 0x32, 0x9a, 0x41, 0x18, 0x33, 0x12, 0x38, 0x89, 0x27, 0x62, 0x26, 0x9f, 0xa7, 0xda,
0xbf, 0xcb, 0xc2, 0x68, 0xb0, 0xb8, 0x57, 0xf5, 0xab, 0xaa, 0x45, 0x77, 0xb0, 0x4b, 0x78, 0x2d,
0xd6, 0xa4, 0xf8, 0x57, 0x59, 0x18, 0x67, 0x0e, 0x77, 0x08, 0x97, 0xc2, 0xc5, 0x2b, 0x80, 0xfd,
0x46, 0x24, 0x14, 0xc3, 0x3f, 0x3e, 0x4b, 0x9d, 0x44, 0xe6, 0x72, 0xe2, 0x2c, 0x60, 0xc8, 0xbc,
0x6a, 0x0b, 0xdb, 0xa1, 0x75, 0xe5, 0xd6, 0xec, 0xd1, 0xee, 0xa0, 0x83, 0xfd, 0x41, 0x07, 0x9f,
0x07, 0x1d, 0xbc, 0x1d, 0xf5, 0xd6, 0xfe, 0xa8, 0xb7, 0x3e, 0x8e, 0x7a, 0xeb, 0x59, 0xc9, 0xe7,
0x6e, 0x5b, 0x7e, 0x9b, 0xfb, 0xaf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x64, 0x72, 0xc0, 0x5a, 0x90,
0x02, 0x00, 0x00,
}

View File

@@ -0,0 +1,42 @@
syntax = "proto3";
package banned_service.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service AdminSilent {
/** 查询运营规则
* 拿着规则直接用就好了,有就肯定是当前生效的配置
*/
rpc get_shield_rule (AdminSilentGetShieldRuleReq) returns (AdminSilentGetShieldRuleResp);
}
message AdminSilentGetShieldRuleReq {
//
int64 roomid = 1 [(gogoproto.jsontag) = "roomid"];
}
message AdminSilentGetShieldRuleResp {
//
int64 code = 1 [(gogoproto.jsontag) = "code"];
//
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
//
int64 id = 1 [(gogoproto.jsontag) = "id"];
// 为0表示全局规则
int64 roomid = 2 [(gogoproto.jsontag) = "roomid"];
// 房间真实分要求
int64 real_score = 3 [(gogoproto.jsontag) = "real_score"];
// 范围0~10, 乘以了10
int64 ai_score = 4 [(gogoproto.jsontag) = "ai_score"];
}
}

View File

@@ -0,0 +1,70 @@
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 = [
"AdminSilent.proto",
"Shield.proto",
"ShieldMng.proto",
"Silent.proto",
"SilentMng.proto",
"SiteBlockMng.proto",
],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "v1_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/service/live/banned_service/api/liverpc/v1",
proto = ":v1_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = [
"AdminSilent.liverpc.go",
"Shield.liverpc.go",
"ShieldMng.liverpc.go",
"Silent.liverpc.go",
"SilentMng.liverpc.go",
"SiteBlockMng.liverpc.go",
],
embed = [":v1_go_proto"],
importpath = "go-common/app/service/live/banned_service/api/liverpc/v1",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/liverpc:go_default_library",
"@com_github_gogo_protobuf//gogoproto: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,46 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v1/Shield.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
// ================
// Shield Interface
// ================
type Shield interface {
// * 是否是屏蔽内容
// 用于房主启用过滤之后,查询弹幕内容是否命中关键字
IsShieldContent(context.Context, *ShieldIsShieldContentReq) (*ShieldIsShieldContentResp, error)
}
// ======================
// Shield Live Rpc Client
// ======================
type shieldRpcClient struct {
client *liverpc.Client
}
// NewShieldRpcClient creates a Rpc client that implements the Shield interface.
// It communicates using Rpc and can be configured with a custom HTTPClient.
func NewShieldRpcClient(client *liverpc.Client) Shield {
return &shieldRpcClient{
client: client,
}
}
func (c *shieldRpcClient) IsShieldContent(ctx context.Context, in *ShieldIsShieldContentReq) (*ShieldIsShieldContentResp, error) {
out := new(ShieldIsShieldContentResp)
err := doRpcRequest(ctx, c.client, 1, "Shield.is_shield_content", in, out)
if err != nil {
return nil, err
}
return out, nil
}

View File

@@ -0,0 +1,871 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: v1/Shield.proto
package v1
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type ShieldIsShieldContentReq struct {
// 房主uid
Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid"`
// 内容
Content string `protobuf:"bytes,2,opt,name=content,proto3" json:"content"`
}
func (m *ShieldIsShieldContentReq) Reset() { *m = ShieldIsShieldContentReq{} }
func (m *ShieldIsShieldContentReq) String() string { return proto.CompactTextString(m) }
func (*ShieldIsShieldContentReq) ProtoMessage() {}
func (*ShieldIsShieldContentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_Shield_14b4a725a4fd2eaf, []int{0}
}
func (m *ShieldIsShieldContentReq) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ShieldIsShieldContentReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ShieldIsShieldContentReq.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *ShieldIsShieldContentReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_ShieldIsShieldContentReq.Merge(dst, src)
}
func (m *ShieldIsShieldContentReq) XXX_Size() int {
return m.Size()
}
func (m *ShieldIsShieldContentReq) XXX_DiscardUnknown() {
xxx_messageInfo_ShieldIsShieldContentReq.DiscardUnknown(m)
}
var xxx_messageInfo_ShieldIsShieldContentReq proto.InternalMessageInfo
func (m *ShieldIsShieldContentReq) GetUid() int64 {
if m != nil {
return m.Uid
}
return 0
}
func (m *ShieldIsShieldContentReq) GetContent() string {
if m != nil {
return m.Content
}
return ""
}
type ShieldIsShieldContentResp struct {
//
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code"`
//
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"`
//
Data *ShieldIsShieldContentResp_Data `protobuf:"bytes,3,opt,name=data" json:"data"`
}
func (m *ShieldIsShieldContentResp) Reset() { *m = ShieldIsShieldContentResp{} }
func (m *ShieldIsShieldContentResp) String() string { return proto.CompactTextString(m) }
func (*ShieldIsShieldContentResp) ProtoMessage() {}
func (*ShieldIsShieldContentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_Shield_14b4a725a4fd2eaf, []int{1}
}
func (m *ShieldIsShieldContentResp) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ShieldIsShieldContentResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ShieldIsShieldContentResp.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *ShieldIsShieldContentResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_ShieldIsShieldContentResp.Merge(dst, src)
}
func (m *ShieldIsShieldContentResp) XXX_Size() int {
return m.Size()
}
func (m *ShieldIsShieldContentResp) XXX_DiscardUnknown() {
xxx_messageInfo_ShieldIsShieldContentResp.DiscardUnknown(m)
}
var xxx_messageInfo_ShieldIsShieldContentResp proto.InternalMessageInfo
func (m *ShieldIsShieldContentResp) GetCode() int64 {
if m != nil {
return m.Code
}
return 0
}
func (m *ShieldIsShieldContentResp) GetMsg() string {
if m != nil {
return m.Msg
}
return ""
}
func (m *ShieldIsShieldContentResp) GetData() *ShieldIsShieldContentResp_Data {
if m != nil {
return m.Data
}
return nil
}
type ShieldIsShieldContentResp_Data struct {
//
Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid"`
// 是否是被屏蔽的内容
IsShieldContent bool `protobuf:"varint,2,opt,name=is_shield_content,json=isShieldContent,proto3" json:"is_shield_content"`
// 命中的屏蔽词
ShieldBy string `protobuf:"bytes,3,opt,name=shield_by,json=shieldBy,proto3" json:"shield_by"`
}
func (m *ShieldIsShieldContentResp_Data) Reset() { *m = ShieldIsShieldContentResp_Data{} }
func (m *ShieldIsShieldContentResp_Data) String() string { return proto.CompactTextString(m) }
func (*ShieldIsShieldContentResp_Data) ProtoMessage() {}
func (*ShieldIsShieldContentResp_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_Shield_14b4a725a4fd2eaf, []int{1, 0}
}
func (m *ShieldIsShieldContentResp_Data) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ShieldIsShieldContentResp_Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ShieldIsShieldContentResp_Data.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *ShieldIsShieldContentResp_Data) XXX_Merge(src proto.Message) {
xxx_messageInfo_ShieldIsShieldContentResp_Data.Merge(dst, src)
}
func (m *ShieldIsShieldContentResp_Data) XXX_Size() int {
return m.Size()
}
func (m *ShieldIsShieldContentResp_Data) XXX_DiscardUnknown() {
xxx_messageInfo_ShieldIsShieldContentResp_Data.DiscardUnknown(m)
}
var xxx_messageInfo_ShieldIsShieldContentResp_Data proto.InternalMessageInfo
func (m *ShieldIsShieldContentResp_Data) GetUid() int64 {
if m != nil {
return m.Uid
}
return 0
}
func (m *ShieldIsShieldContentResp_Data) GetIsShieldContent() bool {
if m != nil {
return m.IsShieldContent
}
return false
}
func (m *ShieldIsShieldContentResp_Data) GetShieldBy() string {
if m != nil {
return m.ShieldBy
}
return ""
}
func init() {
proto.RegisterType((*ShieldIsShieldContentReq)(nil), "banned_service.v1.ShieldIsShieldContentReq")
proto.RegisterType((*ShieldIsShieldContentResp)(nil), "banned_service.v1.ShieldIsShieldContentResp")
proto.RegisterType((*ShieldIsShieldContentResp_Data)(nil), "banned_service.v1.ShieldIsShieldContentResp.Data")
}
func (m *ShieldIsShieldContentReq) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *ShieldIsShieldContentReq) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Uid != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintShield(dAtA, i, uint64(m.Uid))
}
if len(m.Content) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintShield(dAtA, i, uint64(len(m.Content)))
i += copy(dAtA[i:], m.Content)
}
return i, nil
}
func (m *ShieldIsShieldContentResp) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *ShieldIsShieldContentResp) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Code != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintShield(dAtA, i, uint64(m.Code))
}
if len(m.Msg) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintShield(dAtA, i, uint64(len(m.Msg)))
i += copy(dAtA[i:], m.Msg)
}
if m.Data != nil {
dAtA[i] = 0x1a
i++
i = encodeVarintShield(dAtA, i, uint64(m.Data.Size()))
n1, err := m.Data.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n1
}
return i, nil
}
func (m *ShieldIsShieldContentResp_Data) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *ShieldIsShieldContentResp_Data) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Uid != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintShield(dAtA, i, uint64(m.Uid))
}
if m.IsShieldContent {
dAtA[i] = 0x10
i++
if m.IsShieldContent {
dAtA[i] = 1
} else {
dAtA[i] = 0
}
i++
}
if len(m.ShieldBy) > 0 {
dAtA[i] = 0x1a
i++
i = encodeVarintShield(dAtA, i, uint64(len(m.ShieldBy)))
i += copy(dAtA[i:], m.ShieldBy)
}
return i, nil
}
func encodeVarintShield(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *ShieldIsShieldContentReq) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Uid != 0 {
n += 1 + sovShield(uint64(m.Uid))
}
l = len(m.Content)
if l > 0 {
n += 1 + l + sovShield(uint64(l))
}
return n
}
func (m *ShieldIsShieldContentResp) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Code != 0 {
n += 1 + sovShield(uint64(m.Code))
}
l = len(m.Msg)
if l > 0 {
n += 1 + l + sovShield(uint64(l))
}
if m.Data != nil {
l = m.Data.Size()
n += 1 + l + sovShield(uint64(l))
}
return n
}
func (m *ShieldIsShieldContentResp_Data) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Uid != 0 {
n += 1 + sovShield(uint64(m.Uid))
}
if m.IsShieldContent {
n += 2
}
l = len(m.ShieldBy)
if l > 0 {
n += 1 + l + sovShield(uint64(l))
}
return n
}
func sovShield(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozShield(x uint64) (n int) {
return sovShield(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *ShieldIsShieldContentReq) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShield
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: ShieldIsShieldContentReq: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: ShieldIsShieldContentReq: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Uid", wireType)
}
m.Uid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShield
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Uid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShield
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthShield
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Content = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipShield(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthShield
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *ShieldIsShieldContentResp) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShield
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: ShieldIsShieldContentResp: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: ShieldIsShieldContentResp: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
}
m.Code = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShield
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Code |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShield
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthShield
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Msg = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShield
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthShield
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Data == nil {
m.Data = &ShieldIsShieldContentResp_Data{}
}
if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipShield(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthShield
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *ShieldIsShieldContentResp_Data) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShield
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Data: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Data: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Uid", wireType)
}
m.Uid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShield
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Uid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field IsShieldContent", wireType)
}
var v int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShield
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
v |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
m.IsShieldContent = bool(v != 0)
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ShieldBy", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShield
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthShield
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ShieldBy = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipShield(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthShield
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipShield(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowShield
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowShield
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowShield
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthShield
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowShield
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipShield(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthShield = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowShield = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("v1/Shield.proto", fileDescriptor_Shield_14b4a725a4fd2eaf) }
var fileDescriptor_Shield_14b4a725a4fd2eaf = []byte{
// 351 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xe2, 0x2f, 0x33, 0xd4, 0x0f,
0xce, 0xc8, 0x4c, 0xcd, 0x49, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12, 0x4c, 0x4a, 0xcc,
0xcb, 0x4b, 0x4d, 0x89, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b, 0x33, 0x94, 0xd2,
0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf, 0x4f, 0xcf, 0xd7,
0x07, 0xab, 0x4c, 0x2a, 0x4d, 0x03, 0xf3, 0xc0, 0x1c, 0x30, 0x0b, 0x62, 0x82, 0x52, 0x0c, 0x97,
0x04, 0xc4, 0x44, 0xcf, 0x62, 0x08, 0xed, 0x9c, 0x9f, 0x57, 0x92, 0x9a, 0x57, 0x12, 0x94, 0x5a,
0x28, 0x24, 0xc9, 0xc5, 0x5c, 0x9a, 0x99, 0x22, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0xec, 0xc4, 0xfe,
0xea, 0x9e, 0x3c, 0x88, 0x1b, 0x04, 0x22, 0x84, 0x54, 0xb9, 0xd8, 0x93, 0x21, 0x0a, 0x25, 0x98,
0x14, 0x18, 0x35, 0x38, 0x9d, 0xb8, 0x5f, 0xdd, 0x93, 0x87, 0x09, 0x05, 0xc1, 0x18, 0x4a, 0x3b,
0x98, 0xb8, 0x24, 0x71, 0x18, 0x5f, 0x5c, 0x20, 0x24, 0xc3, 0xc5, 0x92, 0x9c, 0x9f, 0x92, 0x0a,
0xb5, 0x80, 0xe3, 0xd5, 0x3d, 0x79, 0x30, 0x3f, 0x08, 0x4c, 0x82, 0x6c, 0xcf, 0x2d, 0x4e, 0x87,
0x1a, 0x0f, 0xb6, 0x3d, 0xb7, 0x38, 0x3d, 0x08, 0x44, 0x08, 0xf9, 0x73, 0xb1, 0xa4, 0x24, 0x96,
0x24, 0x4a, 0x30, 0x2b, 0x30, 0x6a, 0x70, 0x1b, 0x19, 0xea, 0x61, 0x84, 0x82, 0x1e, 0x4e, 0x4b,
0xf5, 0x5c, 0x12, 0x4b, 0x12, 0x21, 0x76, 0x81, 0x8c, 0x08, 0x02, 0x93, 0x52, 0x13, 0x18, 0xb9,
0x58, 0x40, 0x12, 0xf8, 0xbc, 0xec, 0xc8, 0x25, 0x98, 0x59, 0x1c, 0x5f, 0x0c, 0x36, 0x30, 0x1e,
0xd9, 0xf3, 0x1c, 0x4e, 0xa2, 0xaf, 0xee, 0xc9, 0x63, 0x4a, 0x06, 0xf1, 0x67, 0xa2, 0xda, 0x2f,
0xa4, 0xc5, 0xc5, 0x09, 0x55, 0x92, 0x54, 0x09, 0x76, 0x3c, 0xa7, 0x13, 0xef, 0xab, 0x7b, 0xf2,
0x08, 0xc1, 0x20, 0x0e, 0x08, 0xd3, 0xa9, 0xd2, 0xa8, 0x82, 0x8b, 0x0d, 0xa2, 0x59, 0x28, 0x0f,
0x8b, 0xc5, 0x42, 0xda, 0xc4, 0x7b, 0xba, 0x50, 0x4a, 0x87, 0x94, 0x10, 0x72, 0x92, 0x39, 0xf1,
0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8,
0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, 0x28, 0xa6, 0x32, 0xc3, 0x24, 0x36, 0x70, 0xba,
0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x49, 0x4c, 0xac, 0x53, 0x8c, 0x02, 0x00, 0x00,
}

View File

@@ -0,0 +1,42 @@
syntax = "proto3";
package banned_service.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service Shield {
/** 是否是屏蔽内容
* 用于房主启用过滤之后,查询弹幕内容是否命中关键字
*/
rpc is_shield_content (ShieldIsShieldContentReq) returns (ShieldIsShieldContentResp);
}
message ShieldIsShieldContentReq {
// 房主uid
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
// 内容
string content = 2 [(gogoproto.jsontag) = "content"];
}
message ShieldIsShieldContentResp {
//
int64 code = 1 [(gogoproto.jsontag) = "code"];
//
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
//
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
// 是否是被屏蔽的内容
bool is_shield_content = 2 [(gogoproto.jsontag) = "is_shield_content"];
// 命中的屏蔽词
string shield_by = 3 [(gogoproto.jsontag) = "shield_by"];
}
}

View File

@@ -0,0 +1,46 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v1/ShieldMng.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
// ===================
// ShieldMng Interface
// ===================
type ShieldMng interface {
// * 查询用户是否被屏蔽
//
IsShieldUser(context.Context, *ShieldMngIsShieldUserReq) (*ShieldMngIsShieldUserResp, error)
}
// =========================
// ShieldMng Live Rpc Client
// =========================
type shieldMngRpcClient struct {
client *liverpc.Client
}
// NewShieldMngRpcClient creates a Rpc client that implements the ShieldMng interface.
// It communicates using Rpc and can be configured with a custom HTTPClient.
func NewShieldMngRpcClient(client *liverpc.Client) ShieldMng {
return &shieldMngRpcClient{
client: client,
}
}
func (c *shieldMngRpcClient) IsShieldUser(ctx context.Context, in *ShieldMngIsShieldUserReq) (*ShieldMngIsShieldUserResp, error) {
out := new(ShieldMngIsShieldUserResp)
err := doRpcRequest(ctx, c.client, 1, "ShieldMng.is_shield_user", in, out)
if err != nil {
return nil, err
}
return out, nil
}

View File

@@ -0,0 +1,846 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: v1/ShieldMng.proto
package v1
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type ShieldMngIsShieldUserReq struct {
//
Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid"`
//
ShieldUid int64 `protobuf:"varint,2,opt,name=shield_uid,json=shieldUid,proto3" json:"shield_uid"`
}
func (m *ShieldMngIsShieldUserReq) Reset() { *m = ShieldMngIsShieldUserReq{} }
func (m *ShieldMngIsShieldUserReq) String() string { return proto.CompactTextString(m) }
func (*ShieldMngIsShieldUserReq) ProtoMessage() {}
func (*ShieldMngIsShieldUserReq) Descriptor() ([]byte, []int) {
return fileDescriptor_ShieldMng_c683407439c9b594, []int{0}
}
func (m *ShieldMngIsShieldUserReq) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ShieldMngIsShieldUserReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ShieldMngIsShieldUserReq.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *ShieldMngIsShieldUserReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_ShieldMngIsShieldUserReq.Merge(dst, src)
}
func (m *ShieldMngIsShieldUserReq) XXX_Size() int {
return m.Size()
}
func (m *ShieldMngIsShieldUserReq) XXX_DiscardUnknown() {
xxx_messageInfo_ShieldMngIsShieldUserReq.DiscardUnknown(m)
}
var xxx_messageInfo_ShieldMngIsShieldUserReq proto.InternalMessageInfo
func (m *ShieldMngIsShieldUserReq) GetUid() int64 {
if m != nil {
return m.Uid
}
return 0
}
func (m *ShieldMngIsShieldUserReq) GetShieldUid() int64 {
if m != nil {
return m.ShieldUid
}
return 0
}
type ShieldMngIsShieldUserResp struct {
//
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code"`
//
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"`
//
Data *ShieldMngIsShieldUserResp_Data `protobuf:"bytes,3,opt,name=data" json:"data"`
}
func (m *ShieldMngIsShieldUserResp) Reset() { *m = ShieldMngIsShieldUserResp{} }
func (m *ShieldMngIsShieldUserResp) String() string { return proto.CompactTextString(m) }
func (*ShieldMngIsShieldUserResp) ProtoMessage() {}
func (*ShieldMngIsShieldUserResp) Descriptor() ([]byte, []int) {
return fileDescriptor_ShieldMng_c683407439c9b594, []int{1}
}
func (m *ShieldMngIsShieldUserResp) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ShieldMngIsShieldUserResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ShieldMngIsShieldUserResp.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *ShieldMngIsShieldUserResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_ShieldMngIsShieldUserResp.Merge(dst, src)
}
func (m *ShieldMngIsShieldUserResp) XXX_Size() int {
return m.Size()
}
func (m *ShieldMngIsShieldUserResp) XXX_DiscardUnknown() {
xxx_messageInfo_ShieldMngIsShieldUserResp.DiscardUnknown(m)
}
var xxx_messageInfo_ShieldMngIsShieldUserResp proto.InternalMessageInfo
func (m *ShieldMngIsShieldUserResp) GetCode() int64 {
if m != nil {
return m.Code
}
return 0
}
func (m *ShieldMngIsShieldUserResp) GetMsg() string {
if m != nil {
return m.Msg
}
return ""
}
func (m *ShieldMngIsShieldUserResp) GetData() *ShieldMngIsShieldUserResp_Data {
if m != nil {
return m.Data
}
return nil
}
type ShieldMngIsShieldUserResp_Data struct {
//
Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid"`
//
ShieldUid int64 `protobuf:"varint,2,opt,name=shield_uid,json=shieldUid,proto3" json:"shield_uid"`
//
IsShieldUser bool `protobuf:"varint,3,opt,name=is_shield_user,json=isShieldUser,proto3" json:"is_shield_user"`
}
func (m *ShieldMngIsShieldUserResp_Data) Reset() { *m = ShieldMngIsShieldUserResp_Data{} }
func (m *ShieldMngIsShieldUserResp_Data) String() string { return proto.CompactTextString(m) }
func (*ShieldMngIsShieldUserResp_Data) ProtoMessage() {}
func (*ShieldMngIsShieldUserResp_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_ShieldMng_c683407439c9b594, []int{1, 0}
}
func (m *ShieldMngIsShieldUserResp_Data) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *ShieldMngIsShieldUserResp_Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_ShieldMngIsShieldUserResp_Data.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *ShieldMngIsShieldUserResp_Data) XXX_Merge(src proto.Message) {
xxx_messageInfo_ShieldMngIsShieldUserResp_Data.Merge(dst, src)
}
func (m *ShieldMngIsShieldUserResp_Data) XXX_Size() int {
return m.Size()
}
func (m *ShieldMngIsShieldUserResp_Data) XXX_DiscardUnknown() {
xxx_messageInfo_ShieldMngIsShieldUserResp_Data.DiscardUnknown(m)
}
var xxx_messageInfo_ShieldMngIsShieldUserResp_Data proto.InternalMessageInfo
func (m *ShieldMngIsShieldUserResp_Data) GetUid() int64 {
if m != nil {
return m.Uid
}
return 0
}
func (m *ShieldMngIsShieldUserResp_Data) GetShieldUid() int64 {
if m != nil {
return m.ShieldUid
}
return 0
}
func (m *ShieldMngIsShieldUserResp_Data) GetIsShieldUser() bool {
if m != nil {
return m.IsShieldUser
}
return false
}
func init() {
proto.RegisterType((*ShieldMngIsShieldUserReq)(nil), "banned_service.v1.ShieldMngIsShieldUserReq")
proto.RegisterType((*ShieldMngIsShieldUserResp)(nil), "banned_service.v1.ShieldMngIsShieldUserResp")
proto.RegisterType((*ShieldMngIsShieldUserResp_Data)(nil), "banned_service.v1.ShieldMngIsShieldUserResp.Data")
}
func (m *ShieldMngIsShieldUserReq) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *ShieldMngIsShieldUserReq) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Uid != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintShieldMng(dAtA, i, uint64(m.Uid))
}
if m.ShieldUid != 0 {
dAtA[i] = 0x10
i++
i = encodeVarintShieldMng(dAtA, i, uint64(m.ShieldUid))
}
return i, nil
}
func (m *ShieldMngIsShieldUserResp) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *ShieldMngIsShieldUserResp) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Code != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintShieldMng(dAtA, i, uint64(m.Code))
}
if len(m.Msg) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintShieldMng(dAtA, i, uint64(len(m.Msg)))
i += copy(dAtA[i:], m.Msg)
}
if m.Data != nil {
dAtA[i] = 0x1a
i++
i = encodeVarintShieldMng(dAtA, i, uint64(m.Data.Size()))
n1, err := m.Data.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n1
}
return i, nil
}
func (m *ShieldMngIsShieldUserResp_Data) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *ShieldMngIsShieldUserResp_Data) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Uid != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintShieldMng(dAtA, i, uint64(m.Uid))
}
if m.ShieldUid != 0 {
dAtA[i] = 0x10
i++
i = encodeVarintShieldMng(dAtA, i, uint64(m.ShieldUid))
}
if m.IsShieldUser {
dAtA[i] = 0x18
i++
if m.IsShieldUser {
dAtA[i] = 1
} else {
dAtA[i] = 0
}
i++
}
return i, nil
}
func encodeVarintShieldMng(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *ShieldMngIsShieldUserReq) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Uid != 0 {
n += 1 + sovShieldMng(uint64(m.Uid))
}
if m.ShieldUid != 0 {
n += 1 + sovShieldMng(uint64(m.ShieldUid))
}
return n
}
func (m *ShieldMngIsShieldUserResp) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Code != 0 {
n += 1 + sovShieldMng(uint64(m.Code))
}
l = len(m.Msg)
if l > 0 {
n += 1 + l + sovShieldMng(uint64(l))
}
if m.Data != nil {
l = m.Data.Size()
n += 1 + l + sovShieldMng(uint64(l))
}
return n
}
func (m *ShieldMngIsShieldUserResp_Data) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Uid != 0 {
n += 1 + sovShieldMng(uint64(m.Uid))
}
if m.ShieldUid != 0 {
n += 1 + sovShieldMng(uint64(m.ShieldUid))
}
if m.IsShieldUser {
n += 2
}
return n
}
func sovShieldMng(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozShieldMng(x uint64) (n int) {
return sovShieldMng(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *ShieldMngIsShieldUserReq) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShieldMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: ShieldMngIsShieldUserReq: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: ShieldMngIsShieldUserReq: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Uid", wireType)
}
m.Uid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShieldMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Uid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field ShieldUid", wireType)
}
m.ShieldUid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShieldMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.ShieldUid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipShieldMng(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthShieldMng
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *ShieldMngIsShieldUserResp) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShieldMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: ShieldMngIsShieldUserResp: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: ShieldMngIsShieldUserResp: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
}
m.Code = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShieldMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Code |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShieldMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthShieldMng
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Msg = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShieldMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthShieldMng
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Data == nil {
m.Data = &ShieldMngIsShieldUserResp_Data{}
}
if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipShieldMng(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthShieldMng
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *ShieldMngIsShieldUserResp_Data) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShieldMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Data: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Data: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Uid", wireType)
}
m.Uid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShieldMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Uid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field ShieldUid", wireType)
}
m.ShieldUid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShieldMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.ShieldUid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field IsShieldUser", wireType)
}
var v int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowShieldMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
v |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
m.IsShieldUser = bool(v != 0)
default:
iNdEx = preIndex
skippy, err := skipShieldMng(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthShieldMng
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipShieldMng(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowShieldMng
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowShieldMng
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowShieldMng
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthShieldMng
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowShieldMng
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipShieldMng(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthShieldMng = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowShieldMng = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("v1/ShieldMng.proto", fileDescriptor_ShieldMng_c683407439c9b594) }
var fileDescriptor_ShieldMng_c683407439c9b594 = []byte{
// 333 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2a, 0x33, 0xd4, 0x0f,
0xce, 0xc8, 0x4c, 0xcd, 0x49, 0xf1, 0xcd, 0x4b, 0xd7, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0x12,
0x4c, 0x4a, 0xcc, 0xcb, 0x4b, 0x4d, 0x89, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c, 0x4e, 0xd5, 0x2b,
0x33, 0x94, 0xd2, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, 0x4f, 0xcf,
0x4f, 0xcf, 0xd7, 0x07, 0xab, 0x4c, 0x2a, 0x4d, 0x03, 0xf3, 0xc0, 0x1c, 0x30, 0x0b, 0x62, 0x82,
0x52, 0x0a, 0x97, 0x04, 0xdc, 0x50, 0xcf, 0x62, 0x08, 0x33, 0xb4, 0x38, 0xb5, 0x28, 0x28, 0xb5,
0x50, 0x48, 0x92, 0x8b, 0xb9, 0x34, 0x33, 0x45, 0x82, 0x51, 0x81, 0x51, 0x83, 0xd9, 0x89, 0xfd,
0xd5, 0x3d, 0x79, 0x10, 0x37, 0x08, 0x44, 0x08, 0xe9, 0x72, 0x71, 0x15, 0x83, 0xd5, 0xc6, 0x83,
0x54, 0x30, 0x81, 0x55, 0xf0, 0xbd, 0xba, 0x27, 0x8f, 0x24, 0x1a, 0xc4, 0x09, 0x61, 0x87, 0x66,
0xa6, 0x28, 0x6d, 0x62, 0xe2, 0x92, 0xc4, 0x61, 0x4d, 0x71, 0x81, 0x90, 0x0c, 0x17, 0x4b, 0x72,
0x7e, 0x4a, 0x2a, 0xd4, 0x22, 0x8e, 0x57, 0xf7, 0xe4, 0xc1, 0xfc, 0x20, 0x30, 0x09, 0x72, 0x45,
0x6e, 0x71, 0x3a, 0xd8, 0x0e, 0x4e, 0x88, 0x2b, 0x72, 0x8b, 0xd3, 0x83, 0x40, 0x84, 0x90, 0x3f,
0x17, 0x4b, 0x4a, 0x62, 0x49, 0xa2, 0x04, 0xb3, 0x02, 0xa3, 0x06, 0xb7, 0x91, 0xa1, 0x1e, 0x46,
0x68, 0xe8, 0xe1, 0xb4, 0x54, 0xcf, 0x25, 0xb1, 0x24, 0x11, 0x62, 0x17, 0xc8, 0x88, 0x20, 0x30,
0x29, 0xd5, 0xc5, 0xc8, 0xc5, 0x02, 0x92, 0xa0, 0x9e, 0xd7, 0x85, 0x2c, 0xb8, 0xf8, 0x32, 0x8b,
0xe3, 0x61, 0x72, 0xc5, 0xa9, 0x45, 0x60, 0xd7, 0x72, 0x38, 0x09, 0xbd, 0xba, 0x27, 0x8f, 0x26,
0x13, 0xc4, 0x93, 0x89, 0xe4, 0x4a, 0xa3, 0x0a, 0x2e, 0x4e, 0xb8, 0xf3, 0x85, 0xb2, 0xd1, 0x8d,
0x11, 0xd2, 0x26, 0xde, 0xbb, 0x85, 0x52, 0x3a, 0xa4, 0x84, 0x8d, 0x93, 0xcc, 0x89, 0x47, 0x72,
0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7,
0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0x31, 0x95, 0x19, 0x26, 0xb1, 0x81, 0x53, 0x8e, 0x31,
0x20, 0x00, 0x00, 0xff, 0xff, 0x0a, 0xf8, 0x63, 0x71, 0x91, 0x02, 0x00, 0x00,
}

View File

@@ -0,0 +1,42 @@
syntax = "proto3";
package banned_service.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service ShieldMng {
/** 查询用户是否被屏蔽
*
*/
rpc is_shield_user (ShieldMngIsShieldUserReq) returns (ShieldMngIsShieldUserResp);
}
message ShieldMngIsShieldUserReq {
//
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
//
int64 shield_uid = 2 [(gogoproto.jsontag) = "shield_uid"];
}
message ShieldMngIsShieldUserResp {
//
int64 code = 1 [(gogoproto.jsontag) = "code"];
//
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
//
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
//
int64 shield_uid = 2 [(gogoproto.jsontag) = "shield_uid"];
//
bool is_shield_user = 3 [(gogoproto.jsontag) = "is_shield_user"];
}
}

View File

@@ -0,0 +1,46 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v1/Silent.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
// ================
// Silent Interface
// ================
type Silent interface {
// * 获取禁言
//
GetRoomSilent(context.Context, *SilentGetRoomSilentReq) (*SilentGetRoomSilentResp, error)
}
// ======================
// Silent Live Rpc Client
// ======================
type silentRpcClient struct {
client *liverpc.Client
}
// NewSilentRpcClient creates a Rpc client that implements the Silent interface.
// It communicates using Rpc and can be configured with a custom HTTPClient.
func NewSilentRpcClient(client *liverpc.Client) Silent {
return &silentRpcClient{
client: client,
}
}
func (c *silentRpcClient) GetRoomSilent(ctx context.Context, in *SilentGetRoomSilentReq) (*SilentGetRoomSilentResp, error) {
out := new(SilentGetRoomSilentResp)
err := doRpcRequest(ctx, c.client, 1, "Silent.get_room_silent", in, out)
if err != nil {
return nil, err
}
return out, nil
}

View File

@@ -0,0 +1,817 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: v1/Silent.proto
package v1
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type SilentGetRoomSilentReq struct {
//
RoomId int64 `protobuf:"varint,1,opt,name=room_id,json=roomId,proto3" json:"room_id"`
}
func (m *SilentGetRoomSilentReq) Reset() { *m = SilentGetRoomSilentReq{} }
func (m *SilentGetRoomSilentReq) String() string { return proto.CompactTextString(m) }
func (*SilentGetRoomSilentReq) ProtoMessage() {}
func (*SilentGetRoomSilentReq) Descriptor() ([]byte, []int) {
return fileDescriptor_Silent_de6616e052635452, []int{0}
}
func (m *SilentGetRoomSilentReq) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SilentGetRoomSilentReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SilentGetRoomSilentReq.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *SilentGetRoomSilentReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_SilentGetRoomSilentReq.Merge(dst, src)
}
func (m *SilentGetRoomSilentReq) XXX_Size() int {
return m.Size()
}
func (m *SilentGetRoomSilentReq) XXX_DiscardUnknown() {
xxx_messageInfo_SilentGetRoomSilentReq.DiscardUnknown(m)
}
var xxx_messageInfo_SilentGetRoomSilentReq proto.InternalMessageInfo
func (m *SilentGetRoomSilentReq) GetRoomId() int64 {
if m != nil {
return m.RoomId
}
return 0
}
type SilentGetRoomSilentResp struct {
//
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code"`
//
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"`
//
Data *SilentGetRoomSilentResp_Data `protobuf:"bytes,3,opt,name=data" json:"data"`
}
func (m *SilentGetRoomSilentResp) Reset() { *m = SilentGetRoomSilentResp{} }
func (m *SilentGetRoomSilentResp) String() string { return proto.CompactTextString(m) }
func (*SilentGetRoomSilentResp) ProtoMessage() {}
func (*SilentGetRoomSilentResp) Descriptor() ([]byte, []int) {
return fileDescriptor_Silent_de6616e052635452, []int{1}
}
func (m *SilentGetRoomSilentResp) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SilentGetRoomSilentResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SilentGetRoomSilentResp.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *SilentGetRoomSilentResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_SilentGetRoomSilentResp.Merge(dst, src)
}
func (m *SilentGetRoomSilentResp) XXX_Size() int {
return m.Size()
}
func (m *SilentGetRoomSilentResp) XXX_DiscardUnknown() {
xxx_messageInfo_SilentGetRoomSilentResp.DiscardUnknown(m)
}
var xxx_messageInfo_SilentGetRoomSilentResp proto.InternalMessageInfo
func (m *SilentGetRoomSilentResp) GetCode() int64 {
if m != nil {
return m.Code
}
return 0
}
func (m *SilentGetRoomSilentResp) GetMsg() string {
if m != nil {
return m.Msg
}
return ""
}
func (m *SilentGetRoomSilentResp) GetData() *SilentGetRoomSilentResp_Data {
if m != nil {
return m.Data
}
return nil
}
type SilentGetRoomSilentResp_Data struct {
// level等级 medal粉丝勋章等级 member全部
Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type"`
// 等级type=level时为用户等级要求 type为medal为粉丝勋章等级要求 type为member时1表示开启0表示未开启
Level int64 `protobuf:"varint,2,opt,name=level,proto3" json:"level"`
// 还剩多少秒时间到期, -1表示直到直播结束都不过期
Second int64 `protobuf:"varint,3,opt,name=second,proto3" json:"second"`
}
func (m *SilentGetRoomSilentResp_Data) Reset() { *m = SilentGetRoomSilentResp_Data{} }
func (m *SilentGetRoomSilentResp_Data) String() string { return proto.CompactTextString(m) }
func (*SilentGetRoomSilentResp_Data) ProtoMessage() {}
func (*SilentGetRoomSilentResp_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_Silent_de6616e052635452, []int{1, 0}
}
func (m *SilentGetRoomSilentResp_Data) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SilentGetRoomSilentResp_Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SilentGetRoomSilentResp_Data.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *SilentGetRoomSilentResp_Data) XXX_Merge(src proto.Message) {
xxx_messageInfo_SilentGetRoomSilentResp_Data.Merge(dst, src)
}
func (m *SilentGetRoomSilentResp_Data) XXX_Size() int {
return m.Size()
}
func (m *SilentGetRoomSilentResp_Data) XXX_DiscardUnknown() {
xxx_messageInfo_SilentGetRoomSilentResp_Data.DiscardUnknown(m)
}
var xxx_messageInfo_SilentGetRoomSilentResp_Data proto.InternalMessageInfo
func (m *SilentGetRoomSilentResp_Data) GetType() string {
if m != nil {
return m.Type
}
return ""
}
func (m *SilentGetRoomSilentResp_Data) GetLevel() int64 {
if m != nil {
return m.Level
}
return 0
}
func (m *SilentGetRoomSilentResp_Data) GetSecond() int64 {
if m != nil {
return m.Second
}
return 0
}
func init() {
proto.RegisterType((*SilentGetRoomSilentReq)(nil), "banned_service.v1.SilentGetRoomSilentReq")
proto.RegisterType((*SilentGetRoomSilentResp)(nil), "banned_service.v1.SilentGetRoomSilentResp")
proto.RegisterType((*SilentGetRoomSilentResp_Data)(nil), "banned_service.v1.SilentGetRoomSilentResp.Data")
}
func (m *SilentGetRoomSilentReq) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *SilentGetRoomSilentReq) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.RoomId != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintSilent(dAtA, i, uint64(m.RoomId))
}
return i, nil
}
func (m *SilentGetRoomSilentResp) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *SilentGetRoomSilentResp) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Code != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintSilent(dAtA, i, uint64(m.Code))
}
if len(m.Msg) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintSilent(dAtA, i, uint64(len(m.Msg)))
i += copy(dAtA[i:], m.Msg)
}
if m.Data != nil {
dAtA[i] = 0x1a
i++
i = encodeVarintSilent(dAtA, i, uint64(m.Data.Size()))
n1, err := m.Data.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n1
}
return i, nil
}
func (m *SilentGetRoomSilentResp_Data) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *SilentGetRoomSilentResp_Data) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.Type) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintSilent(dAtA, i, uint64(len(m.Type)))
i += copy(dAtA[i:], m.Type)
}
if m.Level != 0 {
dAtA[i] = 0x10
i++
i = encodeVarintSilent(dAtA, i, uint64(m.Level))
}
if m.Second != 0 {
dAtA[i] = 0x18
i++
i = encodeVarintSilent(dAtA, i, uint64(m.Second))
}
return i, nil
}
func encodeVarintSilent(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *SilentGetRoomSilentReq) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.RoomId != 0 {
n += 1 + sovSilent(uint64(m.RoomId))
}
return n
}
func (m *SilentGetRoomSilentResp) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Code != 0 {
n += 1 + sovSilent(uint64(m.Code))
}
l = len(m.Msg)
if l > 0 {
n += 1 + l + sovSilent(uint64(l))
}
if m.Data != nil {
l = m.Data.Size()
n += 1 + l + sovSilent(uint64(l))
}
return n
}
func (m *SilentGetRoomSilentResp_Data) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Type)
if l > 0 {
n += 1 + l + sovSilent(uint64(l))
}
if m.Level != 0 {
n += 1 + sovSilent(uint64(m.Level))
}
if m.Second != 0 {
n += 1 + sovSilent(uint64(m.Second))
}
return n
}
func sovSilent(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozSilent(x uint64) (n int) {
return sovSilent(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *SilentGetRoomSilentReq) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: SilentGetRoomSilentReq: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: SilentGetRoomSilentReq: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field RoomId", wireType)
}
m.RoomId = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.RoomId |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipSilent(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthSilent
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *SilentGetRoomSilentResp) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: SilentGetRoomSilentResp: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: SilentGetRoomSilentResp: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
}
m.Code = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Code |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthSilent
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Msg = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthSilent
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Data == nil {
m.Data = &SilentGetRoomSilentResp_Data{}
}
if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipSilent(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthSilent
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *SilentGetRoomSilentResp_Data) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Data: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Data: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthSilent
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Type = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Level", wireType)
}
m.Level = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Level |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Second", wireType)
}
m.Second = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilent
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Second |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipSilent(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthSilent
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipSilent(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSilent
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSilent
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSilent
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthSilent
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSilent
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipSilent(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthSilent = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowSilent = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("v1/Silent.proto", fileDescriptor_Silent_de6616e052635452) }
var fileDescriptor_Silent_de6616e052635452 = []byte{
// 346 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x51, 0x31, 0x4f, 0xc2, 0x40,
0x14, 0xe6, 0x28, 0x16, 0x79, 0x0c, 0xc4, 0x1b, 0x14, 0x09, 0x69, 0x09, 0x71, 0x40, 0x13, 0xdb,
0x80, 0xbb, 0x43, 0x63, 0x62, 0x1c, 0x5c, 0xce, 0xcd, 0x85, 0xb4, 0xbd, 0xb3, 0x34, 0xa1, 0x3d,
0x68, 0x8f, 0x26, 0xfe, 0x07, 0x07, 0x7f, 0x96, 0x23, 0xa3, 0x53, 0x63, 0x60, 0xeb, 0xaf, 0x30,
0x77, 0x57, 0x27, 0x35, 0x61, 0xf9, 0xde, 0xfb, 0xbe, 0xbc, 0x7e, 0xef, 0x7b, 0x3d, 0xe8, 0x15,
0x53, 0xf7, 0x29, 0x5e, 0xb2, 0x54, 0x38, 0xab, 0x8c, 0x0b, 0x8e, 0x4f, 0x02, 0x3f, 0x4d, 0x19,
0x9d, 0xe7, 0x2c, 0x2b, 0xe2, 0x90, 0x39, 0xc5, 0x74, 0x70, 0x1d, 0xc5, 0x62, 0xb1, 0x09, 0x9c,
0x90, 0x27, 0x6e, 0xc4, 0x23, 0xee, 0xaa, 0xc9, 0x60, 0xf3, 0xa2, 0x98, 0x22, 0xaa, 0xd3, 0x0e,
0xe3, 0x5b, 0x38, 0xd5, 0x8e, 0xf7, 0x4c, 0x10, 0xce, 0x13, 0x4d, 0x08, 0x5b, 0xe3, 0x0b, 0x68,
0x67, 0x9c, 0x27, 0xf3, 0x98, 0xf6, 0xd1, 0x08, 0x4d, 0x0c, 0xaf, 0x5b, 0x95, 0xf6, 0x8f, 0x44,
0x4c, 0xd9, 0x3c, 0xd0, 0xf1, 0x5b, 0x13, 0xce, 0xfe, 0x34, 0xc8, 0x57, 0x78, 0x08, 0xad, 0x90,
0x53, 0x56, 0x7f, 0x7e, 0x5c, 0x95, 0xb6, 0xe2, 0x44, 0x21, 0x3e, 0x07, 0x23, 0xc9, 0xa3, 0x7e,
0x73, 0x84, 0x26, 0x1d, 0xaf, 0x5d, 0x95, 0xb6, 0xa4, 0x44, 0x02, 0x7e, 0x84, 0x16, 0xf5, 0x85,
0xdf, 0x37, 0x46, 0x68, 0xd2, 0x9d, 0xb9, 0xce, 0xaf, 0x2b, 0x9d, 0x7f, 0x56, 0x3a, 0x77, 0xbe,
0xf0, 0xf5, 0x26, 0x69, 0x40, 0x14, 0x0e, 0x62, 0x68, 0x49, 0x5d, 0xe6, 0x11, 0xaf, 0x2b, 0x9d,
0xa7, 0xa3, 0xa7, 0x24, 0x27, 0x0a, 0xb1, 0x0d, 0x47, 0x4b, 0x56, 0xb0, 0xa5, 0x4a, 0x64, 0x78,
0x9d, 0xaa, 0xb4, 0xb5, 0x40, 0x74, 0xc1, 0x63, 0x30, 0x73, 0x16, 0xf2, 0x94, 0xaa, 0x5c, 0x86,
0x07, 0x55, 0x69, 0xd7, 0x0a, 0xa9, 0xeb, 0x2c, 0x03, 0x53, 0xa7, 0xc1, 0x0b, 0xe8, 0x45, 0x4c,
0xcc, 0xd5, 0xff, 0xca, 0xb5, 0x74, 0x79, 0xe8, 0x21, 0xeb, 0xc1, 0xd5, 0xe1, 0x37, 0x7b, 0xc3,
0x8f, 0x9d, 0x85, 0xb6, 0x3b, 0x0b, 0x7d, 0xed, 0x2c, 0xf4, 0xbe, 0xb7, 0x1a, 0xdb, 0xbd, 0xd5,
0xf8, 0xdc, 0x5b, 0x8d, 0xe7, 0x66, 0x31, 0x0d, 0x4c, 0xf5, 0xce, 0x37, 0xdf, 0x01, 0x00, 0x00,
0xff, 0xff, 0xab, 0xb0, 0xfb, 0x98, 0x3c, 0x02, 0x00, 0x00,
}

View File

@@ -0,0 +1,40 @@
syntax = "proto3";
package banned_service.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service Silent {
/** 获取禁言
*
*/
rpc get_room_silent (SilentGetRoomSilentReq) returns (SilentGetRoomSilentResp);
}
message SilentGetRoomSilentReq {
//
int64 room_id = 1 [(gogoproto.jsontag) = "room_id"];
}
message SilentGetRoomSilentResp {
//
int64 code = 1 [(gogoproto.jsontag) = "code"];
//
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
// level等级 medal粉丝勋章等级 member全部
string type = 1 [(gogoproto.jsontag) = "type"];
// 等级type=level时为用户等级要求 type为medal为粉丝勋章等级要求 type为member时1表示开启0表示未开启
int64 level = 2 [(gogoproto.jsontag) = "level"];
// 还剩多少秒时间到期, -1表示直到直播结束都不过期
int64 second = 3 [(gogoproto.jsontag) = "second"];
}
}

View File

@@ -0,0 +1,46 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v1/SilentMng.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
// ===================
// SilentMng Interface
// ===================
type SilentMng interface {
// * 查询是否是黑名单
//
IsBlockUser(context.Context, *SilentMngIsBlockUserReq) (*SilentMngIsBlockUserResp, error)
}
// =========================
// SilentMng Live Rpc Client
// =========================
type silentMngRpcClient struct {
client *liverpc.Client
}
// NewSilentMngRpcClient creates a Rpc client that implements the SilentMng interface.
// It communicates using Rpc and can be configured with a custom HTTPClient.
func NewSilentMngRpcClient(client *liverpc.Client) SilentMng {
return &silentMngRpcClient{
client: client,
}
}
func (c *silentMngRpcClient) IsBlockUser(ctx context.Context, in *SilentMngIsBlockUserReq) (*SilentMngIsBlockUserResp, error) {
out := new(SilentMngIsBlockUserResp)
err := doRpcRequest(ctx, c.client, 1, "SilentMng.is_block_user", in, out)
if err != nil {
return nil, err
}
return out, nil
}

View File

@@ -0,0 +1,958 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: v1/SilentMng.proto
package v1
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type SilentMngIsBlockUserReq struct {
//
Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid"`
//
Roomid int64 `protobuf:"varint,2,opt,name=roomid,proto3" json:"roomid"`
// 1表示弹幕禁言2表示房间信息
Type int64 `protobuf:"varint,3,opt,name=type,proto3" json:"type"`
}
func (m *SilentMngIsBlockUserReq) Reset() { *m = SilentMngIsBlockUserReq{} }
func (m *SilentMngIsBlockUserReq) String() string { return proto.CompactTextString(m) }
func (*SilentMngIsBlockUserReq) ProtoMessage() {}
func (*SilentMngIsBlockUserReq) Descriptor() ([]byte, []int) {
return fileDescriptor_SilentMng_e4a1d159043b9556, []int{0}
}
func (m *SilentMngIsBlockUserReq) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SilentMngIsBlockUserReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SilentMngIsBlockUserReq.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *SilentMngIsBlockUserReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_SilentMngIsBlockUserReq.Merge(dst, src)
}
func (m *SilentMngIsBlockUserReq) XXX_Size() int {
return m.Size()
}
func (m *SilentMngIsBlockUserReq) XXX_DiscardUnknown() {
xxx_messageInfo_SilentMngIsBlockUserReq.DiscardUnknown(m)
}
var xxx_messageInfo_SilentMngIsBlockUserReq proto.InternalMessageInfo
func (m *SilentMngIsBlockUserReq) GetUid() int64 {
if m != nil {
return m.Uid
}
return 0
}
func (m *SilentMngIsBlockUserReq) GetRoomid() int64 {
if m != nil {
return m.Roomid
}
return 0
}
func (m *SilentMngIsBlockUserReq) GetType() int64 {
if m != nil {
return m.Type
}
return 0
}
type SilentMngIsBlockUserResp struct {
//
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code"`
//
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"`
//
Data *SilentMngIsBlockUserResp_Data `protobuf:"bytes,3,opt,name=data" json:"data"`
}
func (m *SilentMngIsBlockUserResp) Reset() { *m = SilentMngIsBlockUserResp{} }
func (m *SilentMngIsBlockUserResp) String() string { return proto.CompactTextString(m) }
func (*SilentMngIsBlockUserResp) ProtoMessage() {}
func (*SilentMngIsBlockUserResp) Descriptor() ([]byte, []int) {
return fileDescriptor_SilentMng_e4a1d159043b9556, []int{1}
}
func (m *SilentMngIsBlockUserResp) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SilentMngIsBlockUserResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SilentMngIsBlockUserResp.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *SilentMngIsBlockUserResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_SilentMngIsBlockUserResp.Merge(dst, src)
}
func (m *SilentMngIsBlockUserResp) XXX_Size() int {
return m.Size()
}
func (m *SilentMngIsBlockUserResp) XXX_DiscardUnknown() {
xxx_messageInfo_SilentMngIsBlockUserResp.DiscardUnknown(m)
}
var xxx_messageInfo_SilentMngIsBlockUserResp proto.InternalMessageInfo
func (m *SilentMngIsBlockUserResp) GetCode() int64 {
if m != nil {
return m.Code
}
return 0
}
func (m *SilentMngIsBlockUserResp) GetMsg() string {
if m != nil {
return m.Msg
}
return ""
}
func (m *SilentMngIsBlockUserResp) GetData() *SilentMngIsBlockUserResp_Data {
if m != nil {
return m.Data
}
return nil
}
type SilentMngIsBlockUserResp_Data struct {
//
Uid int64 `protobuf:"varint,1,opt,name=uid,proto3" json:"uid"`
//
Roomid int64 `protobuf:"varint,2,opt,name=roomid,proto3" json:"roomid"`
//
IsBlockUser bool `protobuf:"varint,3,opt,name=is_block_user,json=isBlockUser,proto3" json:"is_block_user"`
//
Type int64 `protobuf:"varint,4,opt,name=type,proto3" json:"type"`
// 禁言到期时间戳
BlockEndTime int64 `protobuf:"varint,5,opt,name=block_end_time,json=blockEndTime,proto3" json:"block_end_time"`
}
func (m *SilentMngIsBlockUserResp_Data) Reset() { *m = SilentMngIsBlockUserResp_Data{} }
func (m *SilentMngIsBlockUserResp_Data) String() string { return proto.CompactTextString(m) }
func (*SilentMngIsBlockUserResp_Data) ProtoMessage() {}
func (*SilentMngIsBlockUserResp_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_SilentMng_e4a1d159043b9556, []int{1, 0}
}
func (m *SilentMngIsBlockUserResp_Data) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SilentMngIsBlockUserResp_Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SilentMngIsBlockUserResp_Data.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *SilentMngIsBlockUserResp_Data) XXX_Merge(src proto.Message) {
xxx_messageInfo_SilentMngIsBlockUserResp_Data.Merge(dst, src)
}
func (m *SilentMngIsBlockUserResp_Data) XXX_Size() int {
return m.Size()
}
func (m *SilentMngIsBlockUserResp_Data) XXX_DiscardUnknown() {
xxx_messageInfo_SilentMngIsBlockUserResp_Data.DiscardUnknown(m)
}
var xxx_messageInfo_SilentMngIsBlockUserResp_Data proto.InternalMessageInfo
func (m *SilentMngIsBlockUserResp_Data) GetUid() int64 {
if m != nil {
return m.Uid
}
return 0
}
func (m *SilentMngIsBlockUserResp_Data) GetRoomid() int64 {
if m != nil {
return m.Roomid
}
return 0
}
func (m *SilentMngIsBlockUserResp_Data) GetIsBlockUser() bool {
if m != nil {
return m.IsBlockUser
}
return false
}
func (m *SilentMngIsBlockUserResp_Data) GetType() int64 {
if m != nil {
return m.Type
}
return 0
}
func (m *SilentMngIsBlockUserResp_Data) GetBlockEndTime() int64 {
if m != nil {
return m.BlockEndTime
}
return 0
}
func init() {
proto.RegisterType((*SilentMngIsBlockUserReq)(nil), "banned_service.v1.SilentMngIsBlockUserReq")
proto.RegisterType((*SilentMngIsBlockUserResp)(nil), "banned_service.v1.SilentMngIsBlockUserResp")
proto.RegisterType((*SilentMngIsBlockUserResp_Data)(nil), "banned_service.v1.SilentMngIsBlockUserResp.Data")
}
func (m *SilentMngIsBlockUserReq) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *SilentMngIsBlockUserReq) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Uid != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintSilentMng(dAtA, i, uint64(m.Uid))
}
if m.Roomid != 0 {
dAtA[i] = 0x10
i++
i = encodeVarintSilentMng(dAtA, i, uint64(m.Roomid))
}
if m.Type != 0 {
dAtA[i] = 0x18
i++
i = encodeVarintSilentMng(dAtA, i, uint64(m.Type))
}
return i, nil
}
func (m *SilentMngIsBlockUserResp) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *SilentMngIsBlockUserResp) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Code != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintSilentMng(dAtA, i, uint64(m.Code))
}
if len(m.Msg) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintSilentMng(dAtA, i, uint64(len(m.Msg)))
i += copy(dAtA[i:], m.Msg)
}
if m.Data != nil {
dAtA[i] = 0x1a
i++
i = encodeVarintSilentMng(dAtA, i, uint64(m.Data.Size()))
n1, err := m.Data.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n1
}
return i, nil
}
func (m *SilentMngIsBlockUserResp_Data) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *SilentMngIsBlockUserResp_Data) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Uid != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintSilentMng(dAtA, i, uint64(m.Uid))
}
if m.Roomid != 0 {
dAtA[i] = 0x10
i++
i = encodeVarintSilentMng(dAtA, i, uint64(m.Roomid))
}
if m.IsBlockUser {
dAtA[i] = 0x18
i++
if m.IsBlockUser {
dAtA[i] = 1
} else {
dAtA[i] = 0
}
i++
}
if m.Type != 0 {
dAtA[i] = 0x20
i++
i = encodeVarintSilentMng(dAtA, i, uint64(m.Type))
}
if m.BlockEndTime != 0 {
dAtA[i] = 0x28
i++
i = encodeVarintSilentMng(dAtA, i, uint64(m.BlockEndTime))
}
return i, nil
}
func encodeVarintSilentMng(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *SilentMngIsBlockUserReq) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Uid != 0 {
n += 1 + sovSilentMng(uint64(m.Uid))
}
if m.Roomid != 0 {
n += 1 + sovSilentMng(uint64(m.Roomid))
}
if m.Type != 0 {
n += 1 + sovSilentMng(uint64(m.Type))
}
return n
}
func (m *SilentMngIsBlockUserResp) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Code != 0 {
n += 1 + sovSilentMng(uint64(m.Code))
}
l = len(m.Msg)
if l > 0 {
n += 1 + l + sovSilentMng(uint64(l))
}
if m.Data != nil {
l = m.Data.Size()
n += 1 + l + sovSilentMng(uint64(l))
}
return n
}
func (m *SilentMngIsBlockUserResp_Data) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Uid != 0 {
n += 1 + sovSilentMng(uint64(m.Uid))
}
if m.Roomid != 0 {
n += 1 + sovSilentMng(uint64(m.Roomid))
}
if m.IsBlockUser {
n += 2
}
if m.Type != 0 {
n += 1 + sovSilentMng(uint64(m.Type))
}
if m.BlockEndTime != 0 {
n += 1 + sovSilentMng(uint64(m.BlockEndTime))
}
return n
}
func sovSilentMng(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozSilentMng(x uint64) (n int) {
return sovSilentMng(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *SilentMngIsBlockUserReq) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: SilentMngIsBlockUserReq: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: SilentMngIsBlockUserReq: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Uid", wireType)
}
m.Uid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Uid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Roomid", wireType)
}
m.Roomid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Roomid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
}
m.Type = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Type |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipSilentMng(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthSilentMng
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *SilentMngIsBlockUserResp) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: SilentMngIsBlockUserResp: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: SilentMngIsBlockUserResp: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
}
m.Code = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Code |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthSilentMng
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Msg = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthSilentMng
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Data == nil {
m.Data = &SilentMngIsBlockUserResp_Data{}
}
if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipSilentMng(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthSilentMng
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *SilentMngIsBlockUserResp_Data) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Data: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Data: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Uid", wireType)
}
m.Uid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Uid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Roomid", wireType)
}
m.Roomid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Roomid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field IsBlockUser", wireType)
}
var v int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
v |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
m.IsBlockUser = bool(v != 0)
case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType)
}
m.Type = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Type |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 5:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field BlockEndTime", wireType)
}
m.BlockEndTime = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSilentMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.BlockEndTime |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipSilentMng(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthSilentMng
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipSilentMng(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSilentMng
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSilentMng
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSilentMng
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthSilentMng
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSilentMng
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipSilentMng(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthSilentMng = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowSilentMng = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("v1/SilentMng.proto", fileDescriptor_SilentMng_e4a1d159043b9556) }
var fileDescriptor_SilentMng_e4a1d159043b9556 = []byte{
// 385 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x52, 0x3d, 0x4f, 0xe3, 0x40,
0x14, 0x8c, 0x13, 0x5f, 0x2e, 0xd9, 0xdc, 0x9d, 0x94, 0x6d, 0xce, 0x17, 0x45, 0xf6, 0x29, 0x15,
0x02, 0xe1, 0x90, 0x20, 0x24, 0x6a, 0x0b, 0x0a, 0x0a, 0x28, 0x16, 0x68, 0x68, 0x2c, 0x7f, 0x2c,
0xce, 0x8a, 0xd8, 0x9b, 0x78, 0x6d, 0x4b, 0xfc, 0x0b, 0x7e, 0x16, 0x65, 0x0a, 0x0a, 0x2a, 0x0b,
0x25, 0x9d, 0x7f, 0x02, 0x15, 0xda, 0xe7, 0x28, 0x88, 0x10, 0x24, 0x10, 0xcd, 0xd8, 0xe3, 0x79,
0xef, 0xcd, 0x68, 0x64, 0x84, 0xb3, 0x41, 0xff, 0x9c, 0x8d, 0x69, 0x94, 0x9c, 0x46, 0x81, 0x39,
0x89, 0x79, 0xc2, 0x71, 0xdb, 0x75, 0xa2, 0x88, 0xfa, 0xb6, 0xa0, 0x71, 0xc6, 0x3c, 0x6a, 0x66,
0x83, 0xce, 0x6e, 0xc0, 0x92, 0x51, 0xea, 0x9a, 0x1e, 0x0f, 0xfb, 0x01, 0x0f, 0x78, 0x1f, 0x26,
0xdd, 0xf4, 0x1a, 0x18, 0x10, 0x78, 0x2b, 0x2f, 0xf4, 0x32, 0xf4, 0x77, 0x75, 0xf4, 0x44, 0x58,
0x63, 0xee, 0xdd, 0x5c, 0x0a, 0x1a, 0x13, 0x3a, 0xc5, 0xff, 0x50, 0x2d, 0x65, 0xbe, 0xa6, 0xfc,
0x57, 0xb6, 0x6a, 0xd6, 0xcf, 0x22, 0x37, 0x24, 0x25, 0x12, 0x70, 0x0f, 0xd5, 0x63, 0xce, 0x43,
0xe6, 0x6b, 0x55, 0x50, 0x51, 0x91, 0x1b, 0xcb, 0x2f, 0x64, 0xf9, 0xc4, 0x5d, 0xa4, 0x26, 0xb7,
0x13, 0xaa, 0xd5, 0x60, 0xa2, 0x51, 0xe4, 0x06, 0x70, 0x02, 0xd8, 0x7b, 0xae, 0x22, 0x6d, 0xb3,
0xb1, 0x98, 0xc8, 0x55, 0x8f, 0xfb, 0x74, 0x69, 0x0d, 0xab, 0x92, 0x13, 0x40, 0x99, 0x2b, 0x14,
0x01, 0x38, 0x37, 0xcb, 0x5c, 0xa1, 0x08, 0x88, 0x04, 0x7c, 0x86, 0x54, 0xdf, 0x49, 0x1c, 0xf0,
0x6c, 0x0d, 0xf7, 0xcc, 0x77, 0xf5, 0x98, 0x1f, 0x79, 0x9a, 0x47, 0x4e, 0xe2, 0x94, 0x56, 0xf2,
0x02, 0x01, 0xec, 0x3c, 0x28, 0x48, 0x95, 0xc2, 0x77, 0xbb, 0x38, 0x40, 0xbf, 0x99, 0xb0, 0x5d,
0x69, 0x68, 0xa7, 0x82, 0xc6, 0x10, 0xb0, 0x61, 0xb5, 0x8b, 0xdc, 0x78, 0x2b, 0x90, 0x16, 0x7b,
0xcd, 0xb5, 0xaa, 0x50, 0xdd, 0x54, 0x21, 0x3e, 0x44, 0x7f, 0xca, 0x45, 0x1a, 0xf9, 0x76, 0xc2,
0x42, 0xaa, 0xfd, 0x80, 0x39, 0x5c, 0xe4, 0xc6, 0x9a, 0x42, 0x7e, 0x01, 0x3f, 0x8e, 0xfc, 0x0b,
0x16, 0xd2, 0x61, 0x8a, 0x9a, 0xab, 0x1e, 0xf0, 0x68, 0x2d, 0x1b, 0xde, 0xfe, 0x74, 0x6d, 0xd3,
0xce, 0xce, 0x17, 0x2a, 0xb6, 0xba, 0xf7, 0x73, 0x5d, 0x99, 0xcd, 0x75, 0xe5, 0x69, 0xae, 0x2b,
0x77, 0x0b, 0xbd, 0x32, 0x5b, 0xe8, 0x95, 0xc7, 0x85, 0x5e, 0xb9, 0xaa, 0x66, 0x03, 0xb7, 0x0e,
0x3f, 0xe4, 0xfe, 0x4b, 0x00, 0x00, 0x00, 0xff, 0xff, 0xdb, 0x55, 0xed, 0x6d, 0xe8, 0x02, 0x00,
0x00,
}

View File

@@ -0,0 +1,48 @@
syntax = "proto3";
package banned_service.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service SilentMng {
/** 查询是否是黑名单
*
*/
rpc is_block_user (SilentMngIsBlockUserReq) returns (SilentMngIsBlockUserResp);
}
message SilentMngIsBlockUserReq {
//
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
//
int64 roomid = 2 [(gogoproto.jsontag) = "roomid"];
// 1表示弹幕禁言2表示房间信息
int64 type = 3 [(gogoproto.jsontag) = "type"];
}
message SilentMngIsBlockUserResp {
//
int64 code = 1 [(gogoproto.jsontag) = "code"];
//
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
//
int64 uid = 1 [(gogoproto.jsontag) = "uid"];
//
int64 roomid = 2 [(gogoproto.jsontag) = "roomid"];
//
bool is_block_user = 3 [(gogoproto.jsontag) = "is_block_user"];
//
int64 type = 4 [(gogoproto.jsontag) = "type"];
// 禁言到期时间戳
int64 block_end_time = 5 [(gogoproto.jsontag) = "block_end_time"];
}
}

View File

@@ -0,0 +1,46 @@
// Code generated by protoc-gen-liverpc v0.1, DO NOT EDIT.
// source: v1/SiteBlockMng.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
// ======================
// SiteBlockMng Interface
// ======================
type SiteBlockMng interface {
// * 是否封禁
// room-ex调用
IsBlockUser(context.Context, *SiteBlockMngIsBlockUserReq) (*SiteBlockMngIsBlockUserResp, error)
}
// ============================
// SiteBlockMng Live Rpc Client
// ============================
type siteBlockMngRpcClient struct {
client *liverpc.Client
}
// NewSiteBlockMngRpcClient creates a Rpc client that implements the SiteBlockMng interface.
// It communicates using Rpc and can be configured with a custom HTTPClient.
func NewSiteBlockMngRpcClient(client *liverpc.Client) SiteBlockMng {
return &siteBlockMngRpcClient{
client: client,
}
}
func (c *siteBlockMngRpcClient) IsBlockUser(ctx context.Context, in *SiteBlockMngIsBlockUserReq) (*SiteBlockMngIsBlockUserResp, error) {
out := new(SiteBlockMngIsBlockUserResp)
err := doRpcRequest(ctx, c.client, 1, "SiteBlockMng.isBlockUser", in, out)
if err != nil {
return nil, err
}
return out, nil
}

View File

@@ -0,0 +1,737 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: v1/SiteBlockMng.proto
package v1
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type SiteBlockMngIsBlockUserReq struct {
//
Tuid int64 `protobuf:"varint,1,opt,name=tuid,proto3" json:"tuid"`
}
func (m *SiteBlockMngIsBlockUserReq) Reset() { *m = SiteBlockMngIsBlockUserReq{} }
func (m *SiteBlockMngIsBlockUserReq) String() string { return proto.CompactTextString(m) }
func (*SiteBlockMngIsBlockUserReq) ProtoMessage() {}
func (*SiteBlockMngIsBlockUserReq) Descriptor() ([]byte, []int) {
return fileDescriptor_SiteBlockMng_7cdfb51c66347671, []int{0}
}
func (m *SiteBlockMngIsBlockUserReq) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SiteBlockMngIsBlockUserReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SiteBlockMngIsBlockUserReq.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *SiteBlockMngIsBlockUserReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_SiteBlockMngIsBlockUserReq.Merge(dst, src)
}
func (m *SiteBlockMngIsBlockUserReq) XXX_Size() int {
return m.Size()
}
func (m *SiteBlockMngIsBlockUserReq) XXX_DiscardUnknown() {
xxx_messageInfo_SiteBlockMngIsBlockUserReq.DiscardUnknown(m)
}
var xxx_messageInfo_SiteBlockMngIsBlockUserReq proto.InternalMessageInfo
func (m *SiteBlockMngIsBlockUserReq) GetTuid() int64 {
if m != nil {
return m.Tuid
}
return 0
}
type SiteBlockMngIsBlockUserResp struct {
// code
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code"`
// msg
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"`
//
Data *SiteBlockMngIsBlockUserResp_Data `protobuf:"bytes,3,opt,name=data" json:"data"`
}
func (m *SiteBlockMngIsBlockUserResp) Reset() { *m = SiteBlockMngIsBlockUserResp{} }
func (m *SiteBlockMngIsBlockUserResp) String() string { return proto.CompactTextString(m) }
func (*SiteBlockMngIsBlockUserResp) ProtoMessage() {}
func (*SiteBlockMngIsBlockUserResp) Descriptor() ([]byte, []int) {
return fileDescriptor_SiteBlockMng_7cdfb51c66347671, []int{1}
}
func (m *SiteBlockMngIsBlockUserResp) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SiteBlockMngIsBlockUserResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SiteBlockMngIsBlockUserResp.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *SiteBlockMngIsBlockUserResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_SiteBlockMngIsBlockUserResp.Merge(dst, src)
}
func (m *SiteBlockMngIsBlockUserResp) XXX_Size() int {
return m.Size()
}
func (m *SiteBlockMngIsBlockUserResp) XXX_DiscardUnknown() {
xxx_messageInfo_SiteBlockMngIsBlockUserResp.DiscardUnknown(m)
}
var xxx_messageInfo_SiteBlockMngIsBlockUserResp proto.InternalMessageInfo
func (m *SiteBlockMngIsBlockUserResp) GetCode() int64 {
if m != nil {
return m.Code
}
return 0
}
func (m *SiteBlockMngIsBlockUserResp) GetMsg() string {
if m != nil {
return m.Msg
}
return ""
}
func (m *SiteBlockMngIsBlockUserResp) GetData() *SiteBlockMngIsBlockUserResp_Data {
if m != nil {
return m.Data
}
return nil
}
type SiteBlockMngIsBlockUserResp_Data struct {
//
IsBlock bool `protobuf:"varint,1,opt,name=is_block,json=isBlock,proto3" json:"is_block"`
}
func (m *SiteBlockMngIsBlockUserResp_Data) Reset() { *m = SiteBlockMngIsBlockUserResp_Data{} }
func (m *SiteBlockMngIsBlockUserResp_Data) String() string { return proto.CompactTextString(m) }
func (*SiteBlockMngIsBlockUserResp_Data) ProtoMessage() {}
func (*SiteBlockMngIsBlockUserResp_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_SiteBlockMng_7cdfb51c66347671, []int{1, 0}
}
func (m *SiteBlockMngIsBlockUserResp_Data) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *SiteBlockMngIsBlockUserResp_Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_SiteBlockMngIsBlockUserResp_Data.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *SiteBlockMngIsBlockUserResp_Data) XXX_Merge(src proto.Message) {
xxx_messageInfo_SiteBlockMngIsBlockUserResp_Data.Merge(dst, src)
}
func (m *SiteBlockMngIsBlockUserResp_Data) XXX_Size() int {
return m.Size()
}
func (m *SiteBlockMngIsBlockUserResp_Data) XXX_DiscardUnknown() {
xxx_messageInfo_SiteBlockMngIsBlockUserResp_Data.DiscardUnknown(m)
}
var xxx_messageInfo_SiteBlockMngIsBlockUserResp_Data proto.InternalMessageInfo
func (m *SiteBlockMngIsBlockUserResp_Data) GetIsBlock() bool {
if m != nil {
return m.IsBlock
}
return false
}
func init() {
proto.RegisterType((*SiteBlockMngIsBlockUserReq)(nil), "banned_service.v1.SiteBlockMngIsBlockUserReq")
proto.RegisterType((*SiteBlockMngIsBlockUserResp)(nil), "banned_service.v1.SiteBlockMngIsBlockUserResp")
proto.RegisterType((*SiteBlockMngIsBlockUserResp_Data)(nil), "banned_service.v1.SiteBlockMngIsBlockUserResp.Data")
}
func (m *SiteBlockMngIsBlockUserReq) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *SiteBlockMngIsBlockUserReq) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Tuid != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintSiteBlockMng(dAtA, i, uint64(m.Tuid))
}
return i, nil
}
func (m *SiteBlockMngIsBlockUserResp) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *SiteBlockMngIsBlockUserResp) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Code != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintSiteBlockMng(dAtA, i, uint64(m.Code))
}
if len(m.Msg) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintSiteBlockMng(dAtA, i, uint64(len(m.Msg)))
i += copy(dAtA[i:], m.Msg)
}
if m.Data != nil {
dAtA[i] = 0x1a
i++
i = encodeVarintSiteBlockMng(dAtA, i, uint64(m.Data.Size()))
n1, err := m.Data.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n1
}
return i, nil
}
func (m *SiteBlockMngIsBlockUserResp_Data) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *SiteBlockMngIsBlockUserResp_Data) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.IsBlock {
dAtA[i] = 0x8
i++
if m.IsBlock {
dAtA[i] = 1
} else {
dAtA[i] = 0
}
i++
}
return i, nil
}
func encodeVarintSiteBlockMng(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *SiteBlockMngIsBlockUserReq) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Tuid != 0 {
n += 1 + sovSiteBlockMng(uint64(m.Tuid))
}
return n
}
func (m *SiteBlockMngIsBlockUserResp) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Code != 0 {
n += 1 + sovSiteBlockMng(uint64(m.Code))
}
l = len(m.Msg)
if l > 0 {
n += 1 + l + sovSiteBlockMng(uint64(l))
}
if m.Data != nil {
l = m.Data.Size()
n += 1 + l + sovSiteBlockMng(uint64(l))
}
return n
}
func (m *SiteBlockMngIsBlockUserResp_Data) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.IsBlock {
n += 2
}
return n
}
func sovSiteBlockMng(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozSiteBlockMng(x uint64) (n int) {
return sovSiteBlockMng(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *SiteBlockMngIsBlockUserReq) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSiteBlockMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: SiteBlockMngIsBlockUserReq: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: SiteBlockMngIsBlockUserReq: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Tuid", wireType)
}
m.Tuid = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSiteBlockMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Tuid |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipSiteBlockMng(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthSiteBlockMng
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *SiteBlockMngIsBlockUserResp) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSiteBlockMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: SiteBlockMngIsBlockUserResp: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: SiteBlockMngIsBlockUserResp: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
}
m.Code = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSiteBlockMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Code |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSiteBlockMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthSiteBlockMng
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Msg = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSiteBlockMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthSiteBlockMng
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Data == nil {
m.Data = &SiteBlockMngIsBlockUserResp_Data{}
}
if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipSiteBlockMng(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthSiteBlockMng
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *SiteBlockMngIsBlockUserResp_Data) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSiteBlockMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Data: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Data: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field IsBlock", wireType)
}
var v int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowSiteBlockMng
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
v |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
m.IsBlock = bool(v != 0)
default:
iNdEx = preIndex
skippy, err := skipSiteBlockMng(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthSiteBlockMng
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipSiteBlockMng(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSiteBlockMng
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSiteBlockMng
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSiteBlockMng
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthSiteBlockMng
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowSiteBlockMng
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipSiteBlockMng(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthSiteBlockMng = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowSiteBlockMng = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("v1/SiteBlockMng.proto", fileDescriptor_SiteBlockMng_7cdfb51c66347671) }
var fileDescriptor_SiteBlockMng_7cdfb51c66347671 = []byte{
// 308 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x33, 0xd4, 0x0f,
0xce, 0x2c, 0x49, 0x75, 0xca, 0xc9, 0x4f, 0xce, 0xf6, 0xcd, 0x4b, 0xd7, 0x2b, 0x28, 0xca, 0x2f,
0xc9, 0x17, 0x12, 0x4c, 0x4a, 0xcc, 0xcb, 0x4b, 0x4d, 0x89, 0x2f, 0x4e, 0x2d, 0x2a, 0xcb, 0x4c,
0x4e, 0xd5, 0x2b, 0x33, 0x94, 0xd2, 0x4d, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf,
0xd5, 0x4f, 0xcf, 0x4f, 0xcf, 0xd7, 0x07, 0xab, 0x4c, 0x2a, 0x4d, 0x03, 0xf3, 0xc0, 0x1c, 0x30,
0x0b, 0x62, 0x82, 0x92, 0x15, 0x97, 0x14, 0xb2, 0xb9, 0x9e, 0xc5, 0x60, 0x56, 0x68, 0x71, 0x6a,
0x51, 0x50, 0x6a, 0xa1, 0x90, 0x0c, 0x17, 0x4b, 0x49, 0x69, 0x66, 0x8a, 0x04, 0xa3, 0x02, 0xa3,
0x06, 0xb3, 0x13, 0xc7, 0xab, 0x7b, 0xf2, 0x60, 0x7e, 0x10, 0x98, 0x54, 0xba, 0xc5, 0xc8, 0x25,
0x8d, 0x53, 0x73, 0x71, 0x01, 0x48, 0x77, 0x72, 0x7e, 0x4a, 0x2a, 0xb2, 0x6e, 0x10, 0x3f, 0x08,
0x4c, 0x0a, 0x49, 0x72, 0x31, 0xe7, 0x16, 0xa7, 0x4b, 0x30, 0x29, 0x30, 0x6a, 0x70, 0x3a, 0xb1,
0xbf, 0xba, 0x27, 0x0f, 0xe2, 0x06, 0x81, 0x08, 0xa1, 0x40, 0x2e, 0x96, 0x94, 0xc4, 0x92, 0x44,
0x09, 0x66, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x63, 0x3d, 0x0c, 0x5f, 0xea, 0xe1, 0xb1, 0x56, 0xcf,
0x25, 0xb1, 0x24, 0x11, 0x62, 0x1b, 0xc8, 0x90, 0x20, 0x30, 0x29, 0xa5, 0xcf, 0xc5, 0x02, 0x12,
0x17, 0x52, 0xe7, 0xe2, 0xc8, 0x2c, 0x8e, 0x4f, 0x02, 0x69, 0x00, 0xbb, 0x8b, 0xc3, 0x89, 0xe7,
0xd5, 0x3d, 0x79, 0xb8, 0x58, 0x10, 0x7b, 0x26, 0xc4, 0x34, 0xa3, 0x1a, 0x2e, 0x1e, 0x64, 0x4b,
0x84, 0x72, 0xb8, 0xb8, 0x33, 0x11, 0x16, 0x09, 0xe9, 0x92, 0xe2, 0xa8, 0x42, 0x29, 0x3d, 0xd2,
0xfc, 0xe0, 0x24, 0x73, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31,
0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x4c, 0x65,
0x86, 0x49, 0x6c, 0xe0, 0xb8, 0x33, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x00, 0x1b, 0x90, 0xa5,
0x16, 0x02, 0x00, 0x00,
}

View File

@@ -0,0 +1,36 @@
syntax = "proto3";
package banned_service.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service SiteBlockMng {
/** 是否封禁
* room-ex调用
*/
rpc isBlockUser (SiteBlockMngIsBlockUserReq) returns (SiteBlockMngIsBlockUserResp);
}
message SiteBlockMngIsBlockUserReq {
//
int64 tuid = 1 [(gogoproto.jsontag) = "tuid"];
}
message SiteBlockMngIsBlockUserResp {
// code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
Data data = 3 [(gogoproto.jsontag) = "data"];
message Data {
//
bool is_block = 1 [(gogoproto.jsontag) = "is_block"];
}
}

View File

@@ -0,0 +1,5 @@
debug
.idea
*.iml
.vscode
go_install.sh

View File

@@ -0,0 +1,23 @@
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/broadcast-proxy/api/v1:all-srcs",
"//app/service/live/broadcast-proxy/cmd:all-srcs",
"//app/service/live/broadcast-proxy/conf:all-srcs",
"//app/service/live/broadcast-proxy/dispatch:all-srcs",
"//app/service/live/broadcast-proxy/expr:all-srcs",
"//app/service/live/broadcast-proxy/grocery:all-srcs",
"//app/service/live/broadcast-proxy/server:all-srcs",
"//app/service/live/broadcast-proxy/service:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,6 @@
# Owner
majiayi
# Author
# Reviewer

View File

@@ -0,0 +1,10 @@
# See the OWNERS docs at https://go.k8s.io/owners
approvers:
- majiayi
labels:
- live
- service
- service/live/broadcast-proxy
options:
no_parent_owners: true

View File

@@ -0,0 +1,57 @@
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 = ["api.proto"],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "v1_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/service/live/broadcast-proxy/api/v1",
proto = ":v1_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = ["client.go"],
embed = [":v1_go_proto"],
importpath = "go-common/app/service/live/broadcast-proxy/api/v1",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/warden:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_gogo_protobuf//proto:go_default_library",
"@org_golang_google_grpc//:go_default_library",
"@org_golang_x_net//context: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"],
)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,78 @@
syntax = "proto3";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
package live.broadcastproxy.v1;
option go_package = "v1";
service Danmaku {
rpc RoomMessage (RoomMessageRequest) returns (GeneralResponse);
rpc BroadcastMessage (BroadcastMessageRequest) returns(GeneralResponse);
rpc MultiRoomMessage (MultiRoomMessageRequest) returns(GeneralResponse);
rpc BatchRoomMessage(BatchRoomMessageRequest) returns(GeneralResponse);
rpc UserMessage(UserMessageRequest)returns(GeneralResponse);
rpc BatchUserMessage(BatchUserMessageRequest)returns(GeneralResponse);
rpc Dispatch(DispatchRequest)returns(DispatchResponse);
rpc SetAngryValue(SetAngryValueRequest)returns(SetAngryValueResponse);
rpc GetRoomOnlineCount(GetRoomOnlineCountRequest)returns(GetRoomOnlineCountResponse);
}
message GeneralResponse {
}
message RoomMessageRequest {
int32 room_id = 1 [(gogoproto.jsontag) = "room_id"];
string message = 2 [(gogoproto.jsontag) = "msg"];
int32 ensure = 3;
}
message BroadcastMessageRequest {
string message = 1;
repeated int32 exclude_room_id = 2;
}
message MultiRoomMessageRequest {
repeated int32 room_id = 1 [(gogoproto.jsontag) = "room_id"];
string message = 2 [(gogoproto.jsontag) = "msg"];
int32 ensure = 3;
}
message BatchRoomMessageRequest {
repeated RoomMessageRequest room_message = 1 [(gogoproto.jsontag) = "data"];
}
message UserMessageRequest {
int64 user_id = 1 [(gogoproto.jsontag) = "uid"];
string message = 2 [(gogoproto.jsontag) = "msg"];
}
message BatchUserMessageRequest {
repeated UserMessageRequest user_message = 1 [(gogoproto.jsontag) = "data"];
}
message DispatchRequest {
int64 user_id = 1 [(gogoproto.jsontag) = "uid"];
string user_ip = 2 [(gogoproto.jsontag) = "ip"];
}
message DispatchResponse {
repeated string ip = 1 [(gogoproto.jsontag) = "ip"];
repeated string host = 2 [(gogoproto.jsontag) = "host"];
}
message SetAngryValueRequest {
map<uint64,uint64> angry_value = 1 [(gogoproto.jsontag) = "angry_value"];
}
message SetAngryValueResponse {
}
message GetRoomOnlineCountRequest {
repeated uint64 room_id = 1 [(gogoproto.jsontag) = "room_id"];
}
message GetRoomOnlineCountResponse {
map<uint64,uint64> room_online_count = 1 [(gogoproto.jsontag) = "room_online_count"];
}

View File

@@ -0,0 +1,25 @@
package v1
import (
"context"
"go-common/library/net/rpc/warden"
"google.golang.org/grpc"
)
const kAppID = "live.broadcastproxy"
type Client struct {
DanmakuClient
}
// NewClient new resource grpc client
func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (*Client, error) {
client := warden.NewClient(cfg, opts...)
conn, err := client.Dial(context.Background(), "discovery://default/"+kAppID)
if err != nil {
return nil, err
}
cli := &Client{}
cli.DanmakuClient = NewDanmakuClient(conn)
return cli, nil
}

View File

@@ -0,0 +1,42 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "cmd",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
data = ["live-broadcast-proxy.toml"],
importpath = "go-common/app/service/live/broadcast-proxy/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/live/broadcast-proxy/conf:go_default_library",
"//app/service/live/broadcast-proxy/server:go_default_library",
"//app/service/live/broadcast-proxy/service:go_default_library",
"//library/log: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,49 @@
# This is a TOML document. Boom.
version = "1.0.0"
user = "root"
pid = "/tmp/live-broadcast-proxy.pid"
dir = "./"
perf = "0.0.0.0:20215"
family = "live-broadcast-proxy"
trace = true
debug = true
[log]
#dir = "/data/log/broadcast-proxy"
vlevel = 100
stdout = true
[http]
address = "0.0.0.0:20214"
[backend]
maxIdleConnsPerHost = 512
probePath = "/monitor/ping"
backendServer = ["172.18.33.69:7172","172.18.33.119:80", "172.16.38.159:80", "172.16.38.159:7172"]
probesample = 100
[zookeeper]
address = ["172.18.33.171:2182"]
timeout = "5s"
configpath = "/live/setting/live_broadcast_proxy"
[sinaip]
data = "/data/conf/sinaip.dat"
[ipip]
v4= "/data/conf/v4.ipdb"
v6= "/data/conf/v6.ipdb"
[dispatch]
maxlimit = 2
defaultdomain = "broadcastlv.chat.bilibili.com"
wildcarddomainsuffix=".chat.bilibili.com"
filename="dispatch.json"
[sven]
treeID="24639"
zone="sh001"
env="prod"
build="docker-1"
token="768e1f6f4c3f4c545c8c89852c02fea6"

View File

@@ -0,0 +1,80 @@
package main
import (
"context"
"flag"
"go-common/app/service/live/broadcast-proxy/conf"
"go-common/app/service/live/broadcast-proxy/server"
"go-common/app/service/live/broadcast-proxy/service"
"go-common/library/log"
"net/http"
"net/http/pprof"
"runtime"
"time"
)
func RunPprofServer(addr string) {
pprofServer := http.NewServeMux()
pprofServer.Handle("/debug/pprof/", http.HandlerFunc(pprof.Index))
pprofServer.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline))
pprofServer.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile))
pprofServer.Handle("/debug/pprof/symbol", http.HandlerFunc(pprof.Symbol))
pprofServer.Handle("/debug/pprof/trace", http.HandlerFunc(pprof.Trace))
go func() {
if e := http.ListenAndServe(addr, pprofServer); e != nil {
log.Error("pprof server error ListenAndServe addr:%s,error:%+v", addr, e)
}
defer func() {
if e := recover(); e != nil {
log.Error("expected panic from pprof server,error:%+v", e)
}
}()
}()
}
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
var confTomlFile string
flag.StringVar(&confTomlFile, "conf", "", "config file for broadcast proxy")
flag.Parse()
conf, err := conf.NewBroadcastProxyConfig(confTomlFile)
if err != nil {
panic(err)
}
log.Init(conf.Log)
log.Info("Broadcast Proxy Service:%s", time.Now().String())
log.Info("Broadcast Proxy Config:%+v", conf)
proxy, err := server.NewBroadcastProxy(conf.Backend.BackendServer, conf.Backend.ProbePath,
conf.Backend.MaxIdleConnsPerHost, conf.Backend.ProbeSample)
if err != nil {
panic(err)
}
defer proxy.Close()
dispatcher, err := server.NewCometDispatcher(conf.Ipip, conf.Dispatch, conf.Sven)
if err != nil {
panic(err)
}
defer dispatcher.Close()
httpService, err := server.NewBroadcastService(conf.Http.Address, proxy, dispatcher)
if err != nil {
panic(err)
}
defer httpService.Close()
grpcService, err := service.NewGrpcService(proxy, dispatcher)
if err != nil {
panic(err)
}
defer grpcService.Shutdown(context.Background())
RunPprofServer(conf.Perf)
quit := make(chan struct{})
<-quit
}

View File

@@ -0,0 +1,34 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["config.go"],
importpath = "go-common/app/service/live/broadcast-proxy/conf",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/conf:go_default_library",
"//library/log:go_default_library",
"//library/time:go_default_library",
"//vendor/github.com/BurntSushi/toml: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,106 @@
package conf
import (
"errors"
"github.com/BurntSushi/toml"
"go-common/library/conf"
"go-common/library/log"
xtime "go-common/library/time"
)
type BroadcastProxyConfig struct {
Perf string `toml:"perf"`
Log *log.Config
Http *HttpConfig
Backend *BackendConfig
ZooKeeper *ZooKeeperConfig
Ipip *IpipConfig
Dispatch *DispatchConfig
Sven *SvenConfig
}
type HttpConfig struct {
Address string
}
type BackendConfig struct {
MaxIdleConnsPerHost int
ProbePath string
BackendServer []string
ProbeSample int
}
type ZooKeeperConfig struct {
Address []string
Timeout xtime.Duration
ConfigPath string
}
type SinaIPConfig struct {
Data string
}
type IpipConfig struct {
V4 string
V6 string
}
type DispatchConfig struct {
MaxLimit int
DefaultDomain string
WildcardDomainSuffix string
FileName string
}
type SvenConfig struct {
TreeID string
Zone string
Env string
Build string
Token string
}
func NewBroadcastProxyConfig(file string) (*BroadcastProxyConfig, error) {
config := new(BroadcastProxyConfig)
if file != "" {
if err := config.local(file); err != nil {
return nil, err
}
} else {
if err := config.remote(); err != nil {
return nil, err
}
}
return config, nil
}
func (config *BroadcastProxyConfig) local(filename string) (err error) {
_, err = toml.DecodeFile(filename, config)
return
}
func (config *BroadcastProxyConfig) remote() error {
client, err := conf.New()
if err != nil {
return err
}
if err = config.load(client); err != nil {
return err
}
go func() {
for range client.Event() {
log.Info("config event")
}
}()
return nil
}
func (config *BroadcastProxyConfig) load(c *conf.Client) error {
s, ok := c.Value("live-broadcast-proxy.toml")
if !ok {
return errors.New("load config center error")
}
if _, err := toml.Decode(s, config); err != nil {
return errors.New("could not decode config")
}
return nil
}

View File

@@ -0,0 +1,46 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_test",
"go_library",
)
go_test(
name = "go_default_test",
srcs = ["matcher_test.go"],
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = [
"matcher.go",
"min_heap.go",
"sinaip.go",
],
importpath = "go-common/app/service/live/broadcast-proxy/dispatch",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/live/broadcast-proxy/conf:go_default_library",
"//app/service/live/broadcast-proxy/expr:go_default_library",
"//library/log:go_default_library",
"//vendor/github.com/ipipdotnet/ipdb-go: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,306 @@
package dispatch
import (
"encoding/json"
"errors"
"github.com/ipipdotnet/ipdb-go"
"go-common/app/service/live/broadcast-proxy/conf"
"go-common/app/service/live/broadcast-proxy/expr"
"go-common/library/log"
"math"
"math/rand"
"strconv"
"strings"
"sync"
)
type Matcher struct {
ipDataV4 *ipdb.City
ipDataV6 *ipdb.City
heapPool sync.Pool
Config string
MaxLimit int `json:"ip_max_limit"`
DefaultDomain string `json:"default_domain"`
WildcardDomainSuffix string `json:"wildcard_domain_suffix"`
CommonDispatch struct {
ChinaDispatch struct {
ChinaTelecom *CommonBucket `json:"china_telecom"`
ChinaUnicom *CommonBucket `json:"china_unicom"`
CMCC *CommonBucket `json:"cmcc"`
ChinaOther *CommonBucket `json:"other"`
} `json:"china"`
OverseaDispatch []*CommonRuleBucket `json:"oversea"`
UnknownAreaDispatch *CommonBucket `json:"unknown"`
} `json:"danmaku_common_dispatch"`
VIPDispatch []*VIPRuleBucket `json:"danmaku_vip_dispatch"`
ServerGroup map[string][]string `json:"danmaku_comet_group"`
ServerHost map[string]string `json:"danmaku_comet_host"`
IPBlack []string `json:"ip_black"`
TempV6 []string `json:"temp_v6"`
forbiddenIP map[string]struct{}
}
type CommonBucket struct {
Master map[string]int `json:"master"`
Slave map[string]int `json:"slave"`
}
type CommonRuleBucket struct {
CommonBucket
Rule string `json:"rule"`
RuleExpr expr.Expr
}
type VIPRuleBucket struct {
Rule string `json:"rule"`
RuleExpr expr.Expr
IP []string `json:"ip"`
Group []string `json:"group"`
}
func NewMatcher(matcherConfig []byte, ipDataV4 *ipdb.City, ipDataV6 *ipdb.City, dispatchConfig *conf.DispatchConfig) (*Matcher, error) {
matcher := new(Matcher)
matcher.heapPool = sync.Pool{
New: func() interface{} {
return NewMinHeap()
},
}
matcher.forbiddenIP = make(map[string]struct{})
if ipDataV4 == nil || ipDataV6 == nil {
return nil, errors.New("invalid IP database")
}
matcher.ipDataV4 = ipDataV4
matcher.ipDataV6 = ipDataV6
matcher.Config = string(matcherConfig)
if err := json.Unmarshal(matcherConfig, matcher); err != nil {
return nil, err
}
for _, ip := range matcher.IPBlack {
matcher.forbiddenIP[ip] = struct{}{}
}
parser := expr.NewExpressionParser()
for _, oversea := range matcher.CommonDispatch.OverseaDispatch {
if oversea.Rule == "" {
oversea.Rule = "true"
}
if err := parser.Parse(oversea.Rule); err != nil {
log.Error("[Matcher] Parse rule expr:%s, error:%+v", oversea.Rule, err)
return nil, err
}
for _, variable := range parser.GetVariable() {
if variable != "$lng" && variable != "$lat" {
return nil, errors.New("oversea dispatch only supports variable $lng and $lat")
}
}
oversea.RuleExpr = parser.GetExpr()
}
for _, vip := range matcher.VIPDispatch {
if err := parser.Parse(vip.Rule); err != nil {
log.Error("[Matcher] Parse rule expr:%s, error:%+v", vip.Rule, err)
return nil, err
}
for _, variable := range parser.GetVariable() {
if variable != "$uid" {
return nil, errors.New("vip dispatch only supports variable $uid")
}
}
if len(parser.GetVariable()) == 0 {
return nil, errors.New("vip dispatch must contains variable $uid")
}
vip.RuleExpr = parser.GetExpr()
}
if matcher.MaxLimit == 0 && dispatchConfig != nil {
matcher.MaxLimit = dispatchConfig.MaxLimit
}
if matcher.DefaultDomain == "" && dispatchConfig != nil {
matcher.DefaultDomain = dispatchConfig.DefaultDomain
}
if matcher.WildcardDomainSuffix == "" && dispatchConfig != nil {
matcher.WildcardDomainSuffix = dispatchConfig.WildcardDomainSuffix
}
return matcher, nil
}
func (matcher *Matcher) GetConfig() string {
return matcher.Config
}
func (matcher *Matcher) Dispatch(ip string, uid int64) ([]string, []string) {
danmakuIP := matcher.dispatchInternal(ip, uid)
danmakuHost := make([]string, 0, len(danmakuIP))
for _, singleDanmakuIP := range danmakuIP {
if host, ok := matcher.ServerHost[singleDanmakuIP]; ok {
danmakuHost = append(danmakuHost, host+matcher.WildcardDomainSuffix)
}
}
danmakuIP = append(danmakuIP, matcher.DefaultDomain)
danmakuHost = append(danmakuHost, matcher.DefaultDomain)
return danmakuIP, danmakuHost
}
func (matcher *Matcher) dispatchInternal(ip string, uid int64) []string {
if _, ok := matcher.forbiddenIP[ip]; ok {
return []string{}
}
// VIP Dispatch
vipDispatchEnv := make(map[expr.Var]interface{})
vipDispatchEnv[expr.Var("$uid")] = uid
for _, vip := range matcher.VIPDispatch {
if v, err := expr.SafetyEvalBool(vip.RuleExpr, vipDispatchEnv); v && err == nil {
return matcher.pickFromVIPRuleBucket(vip)
} else {
if err != nil {
log.Error("[Matcher] VIP dispatch, uid:%d, eval rule expr:%s error:%+v", uid, vip.Rule, err)
}
}
}
// Common Dispatch
var ipDatabase *ipdb.City
for i := 0; i < len(ip); i++ {
if ip[i] == '.' {
ipDatabase = matcher.ipDataV4
break
} else if ip[i] == ':' {
ipDatabase = matcher.ipDataV6
//break
//TODO: this is temp solution, replace this block with "break" here when all server supports IPv6
return matcher.randomPickN(matcher.TempV6, matcher.MaxLimit)
}
}
if ipDatabase == nil {
return matcher.pickFromCommonBucket(matcher.CommonDispatch.UnknownAreaDispatch)
}
detail, err := ipDatabase.FindMap(ip, "EN")
if err != nil {
return matcher.pickFromCommonBucket(matcher.CommonDispatch.UnknownAreaDispatch)
}
country := strings.TrimSpace(detail["country_name"])
province := strings.TrimSpace(detail["region_name"])
isp := strings.TrimSpace(detail["isp_domain"])
latitude, _ := strconv.ParseFloat(detail["latitude"], 64)
longitude, _ := strconv.ParseFloat(detail["longitude"], 64)
if country != "China" && country != "Reserved" && country != "LAN Address" && country != "Loopback" {
return matcher.pickFromCommonRuleBucket(matcher.CommonDispatch.OverseaDispatch, latitude, longitude)
} else if country == "China" {
if province == "Hong Kong" || province == "Macau" || province == "Taiwan" {
return matcher.pickFromCommonRuleBucket(matcher.CommonDispatch.OverseaDispatch, latitude, longitude)
} else {
switch isp {
case "ChinaTelecom":
return matcher.pickFromCommonBucket(matcher.CommonDispatch.ChinaDispatch.ChinaTelecom)
case "ChinaMobile":
return matcher.pickFromCommonBucket(matcher.CommonDispatch.ChinaDispatch.CMCC)
case "ChinaUnicom":
return matcher.pickFromCommonBucket(matcher.CommonDispatch.ChinaDispatch.ChinaUnicom)
default:
return matcher.pickFromCommonBucket(matcher.CommonDispatch.ChinaDispatch.ChinaOther)
}
}
} else {
return matcher.pickFromCommonBucket(matcher.CommonDispatch.UnknownAreaDispatch)
}
}
func (matcher *Matcher) pickFromCommonRuleBucket(overseaBucket []*CommonRuleBucket, latitude float64, longitude float64) []string {
overseaDispatchEnv := make(map[expr.Var]interface{})
overseaDispatchEnv[expr.Var("$lat")] = latitude
overseaDispatchEnv[expr.Var("$lng")] = longitude
for _, bucket := range overseaBucket {
if v, err := expr.SafetyEvalBool(bucket.RuleExpr, overseaDispatchEnv); v && err == nil {
return matcher.pickFromCommonBucket(&bucket.CommonBucket)
}
}
return []string{}
}
func (matcher *Matcher) pickOneFromWeightedGroup(groupWeightDict map[string]int) (string, string) {
var luckyKey float64
var luckyGroup string
for group, weight := range groupWeightDict {
if weight > 0 {
key := math.Pow(rand.Float64(), 1.0/float64(weight))
if key >= luckyKey {
luckyKey = key
luckyGroup = group
}
}
}
luckyIP := matcher.ServerGroup[luckyGroup]
if len(luckyIP) == 0 {
return "", ""
}
return matcher.randomPickOne(luckyIP), luckyGroup
}
func (matcher *Matcher) pickNFromWeightedGroup(groupWeightDict map[string]int, n int, groupIgnore string) []string {
h := matcher.heapPool.Get().(*MinHeap)
for group, weight := range groupWeightDict {
if group != groupIgnore && weight > 0 {
key := math.Pow(rand.Float64(), 1.0/float64(weight))
if h.HeapLength() < n {
h.HeapPush(group, key)
} else {
_, top, _ := h.HeapTop()
if key > top {
h.HeapPush(group, key)
h.HeapPop()
}
}
}
}
r := make([]string, 0, n)
for h.HeapLength() > 0 {
v, _, _ := h.HeapPop()
member := matcher.ServerGroup[v.(string)]
if len(member) > 0 {
r = append(r, matcher.randomPickOne(member))
}
}
matcher.heapPool.Put(h)
return r
}
func (matcher *Matcher) pickFromCommonBucket(b *CommonBucket) []string {
r := make([]string, 0, matcher.MaxLimit)
masterIP, masterGroup := matcher.pickOneFromWeightedGroup(b.Master)
if masterIP != "" {
r = append(r, masterIP)
}
for _, slaveIP := range matcher.pickNFromWeightedGroup(b.Slave, matcher.MaxLimit-len(r), masterGroup) {
r = append(r, slaveIP)
}
return r
}
func (matcher *Matcher) pickFromVIPRuleBucket(b *VIPRuleBucket) []string {
var length int
for _, group := range b.Group {
length += len(matcher.ServerGroup[group])
}
length += len(b.IP)
candidate := make([]string, length)
i := 0
for _, group := range b.Group {
i += copy(candidate[i:], matcher.ServerGroup[group])
}
i += copy(candidate[i:], b.IP)
return matcher.randomPickN(candidate, matcher.MaxLimit)
}
func (matcher *Matcher) randomPickOne(s []string) string {
return s[rand.Intn(len(s))]
}
func (matcher *Matcher) randomPickN(s []string, n int) []string {
var r []string
if n > len(s) {
n = len(s)
}
for _, v := range rand.Perm(len(s))[0:n] {
r = append(r, s[v])
}
return r
}

View File

@@ -0,0 +1,159 @@
package dispatch
import (
"fmt"
"testing"
)
func TestMatcher(t *testing.T) {
config := []byte(`{
"ip_max_limit": 2,
"default_domain" : "broadcastlv.chat.bilibili.com",
"danmaku_common_dispatch": {
"china" :{
"china_telecom": {
"master": {
"tencent_shanghai": 10,
"tencent_guangzhou": 6,
"kingsoft": 24
},
"slave": {
"tencent_shanghai": 10,
"tencent_guangzhou": 6,
"kingsoft": 24,
"aliyun": 30
}
},
"china_unicom": {
"master": {
"tencent_shanghai": 10,
"tencent_guangzhou": 6,
"kingsoft": 24
},
"slave": {
"tencent_shanghai": 10,
"tencent_guangzhou": 6,
"kingsoft": 24,
"aliyun": 30
}
},
"cmcc": {
"master": {
"tencent_shanghai": 10,
"tencent_guangzhou": 6,
"kingsoft": 24
},
"slave": {
"tencent_shanghai": 10,
"tencent_guangzhou": 6,
"kingsoft": 24,
"aliyun": 30
}
},
"other": {
"master": {
"tencent_shanghai": 10,
"tencent_guangzhou": 6,
"kingsoft": 24
},
"slave": {
"tencent_shanghai": 10,
"tencent_guangzhou": 6,
"kingsoft": 24,
"aliyun": 30
}
}
},
"oversea": [
{
"rule":"($lng >= -20) && ($lng <= 160)",
"master": {
"tencent_siliconvalley": 10
},
"slave": {
"tencent_shanghai": 10,
"tencent_guangzhou": 6,
"kingsoft": 24,
"aliyun": 30
}
},
{
"master": {
"tencent_siliconvalley": 10
},
"slave": {
"tencent_shanghai": 10,
"tencent_guangzhou": 6,
"kingsoft": 24,
"aliyun": 30
}
}
],
"unknown" : {
"master": {
"tencent_shanghai": 10,
"tencent_guangzhou": 6,
"kingsoft": 24
},
"slave": {
"tencent_shanghai": 10,
"tencent_guangzhou": 6,
"kingsoft": 24,
"aliyun": 30
}
}
},
"danmaku_vip_dispatch" : [
{
"rule":"$uid==120497668",
"ip": ["118.89.14.174"]
},
{
"rule":"$uid % 10 == 1",
"group": ["tencent_guangzhou"]
},
{
"rule":"$uid == 221122111"
}
],
"danmaku_comet_group": {
"tencent_shanghai": [
"118.89.14.174",
"118.89.14.115",
"118.89.14.103",
"118.89.14.206",
"118.89.13.229"
],
"tencent_guangzhou": [
"211.159.194.41",
"211.159.194.115",
"211.159.194.105"
],
"tencent_hongkong": [
"119.28.56.183"
],
"tencent_siliconvalley": [
"49.51.37.200"
],
"kingsoft": [
"120.92.78.57",
"120.92.158.137",
"120.92.112.150"
],
"aliyun": [
"101.132.195.89",
"47.104.64.120",
"59.110.167.237",
"47.92.112.162",
"47.96.139.69",
"119.23.41.85"
]
}
}`)
m, err := NewMatcher(config, nil, nil, nil)
if err != nil {
t.Error(err)
t.Fail()
}
fmt.Println(m)
}

View File

@@ -0,0 +1,79 @@
package dispatch
import (
"container/heap"
"errors"
)
type HeapData []*HeapDataItem
type HeapDataItem struct {
value interface{}
weight float64
}
func (d HeapData) Len() int {
return len(d)
}
func (d HeapData) Swap(i, j int) {
d[i], d[j] = d[j], d[i]
}
func (d *HeapData) Push(x interface{}) {
item := x.(*HeapDataItem)
*d = append(*d, item)
}
func (d *HeapData) Pop() interface{} {
old := *d
n := len(old)
item := old[n-1]
*d = old[0 : n-1]
return item
}
type MinHeapData struct {
HeapData
}
func (d MinHeapData) Less(i, j int) bool {
return d.HeapData[i].weight < d.HeapData[j].weight
}
type MinHeap struct {
data MinHeapData
}
func NewMinHeap() *MinHeap {
h := new(MinHeap)
heap.Init(&h.data)
return h
}
func (h *MinHeap) HeapPush(value interface{}, weight float64) {
heap.Push(&h.data, &HeapDataItem{
value: value,
weight: weight,
})
}
func (h *MinHeap) HeapPop() (interface{}, float64, error) {
if h.data.Len() == 0 {
return nil, 0, errors.New("heap is empty")
}
item := heap.Pop(&h.data).(*HeapDataItem)
return item.value, item.weight, nil
}
func (h *MinHeap) HeapTop() (interface{}, float64, error) {
if h.data.Len() == 0 {
return nil, 0, errors.New("heap is empty")
}
item := h.data.HeapData[0]
return item.value, item.weight, nil
}
func (h *MinHeap) HeapLength() int {
return h.data.Len()
}

View File

@@ -0,0 +1,372 @@
package dispatch
import (
"bytes"
"encoding/binary"
"io"
"os"
"syscall"
)
type SinaIP struct {
country map[uint16]*Country
province map[uint16]*Province
city map[uint16]*City
isp map[uint16]*ISP
district map[uint16]*District
segment []*IPSegment
}
type IPDetail struct {
Country string
Province string
City string
ISP string
District string
Latitude float64
Longitude float64
}
type IPSegment struct {
start uint32
end uint32
country *Country
province *Province
city *City
isp *ISP
district *District
latitude float64
longitude float64
}
type Country struct {
name string
}
type Province struct {
name string
}
type City struct {
name string
}
type ISP struct {
name string
}
type District struct {
name string
}
func NewSinaIP(file string) (*SinaIP, error) {
f, err := os.Open(file)
if err != nil {
return nil, err
}
defer f.Close()
info, err := f.Stat()
if err != nil {
return nil, err
}
data, err := syscall.Mmap(int(f.Fd()), 0, int(info.Size()), syscall.PROT_READ, syscall.MAP_PRIVATE)
if err != nil {
return nil, err
}
defer syscall.Munmap(data)
var (
segmentOffset uint32
countryOffset uint32
provinceOffset uint32
cityOffset uint32
ispOffset uint32
districtOffset uint32
)
reader := bytes.NewReader(data[0:24])
if err := binary.Read(reader, binary.BigEndian, &segmentOffset); err != nil {
return nil, err
}
if err := binary.Read(reader, binary.BigEndian, &countryOffset); err != nil {
return nil, err
}
if err := binary.Read(reader, binary.BigEndian, &provinceOffset); err != nil {
return nil, err
}
if err := binary.Read(reader, binary.BigEndian, &cityOffset); err != nil {
return nil, err
}
if err := binary.Read(reader, binary.BigEndian, &ispOffset); err != nil {
return nil, err
}
if err := binary.Read(reader, binary.BigEndian, &districtOffset); err != nil {
return nil, err
}
biliIP := new(SinaIP)
if err := biliIP.loadCity(data[cityOffset:]); err != nil {
return nil, err
}
if err := biliIP.loadCountry(data[countryOffset:]); err != nil {
return nil, err
}
if err := biliIP.loadProvince(data[provinceOffset:]); err != nil {
return nil, err
}
if err := biliIP.loadISP(data[ispOffset:]); err != nil {
return nil, err
}
if err := biliIP.loadDistrict(data[districtOffset:]); err != nil {
return nil, err
}
if err := biliIP.loadIPSegment(data[segmentOffset:]); err != nil {
return nil, err
}
return biliIP, nil
}
func (b *SinaIP) DoQuery(ip uint32) *IPDetail {
left := 0
right := len(b.segment) - 1
var r *IPDetail
for left <= right {
middle := left + (right-left)/2
s := b.segment[middle]
if ip >= s.start && ip <= s.end {
r = new(IPDetail)
if s.country != nil {
r.Country = s.country.name
}
if s.province != nil {
r.Province = s.province.name
}
if s.city != nil {
r.City = s.city.name
}
if s.isp != nil {
r.ISP = s.isp.name
}
if s.district != nil {
r.District = s.district.name
}
r.Latitude = s.latitude
r.Longitude = s.longitude
break
} else if ip < s.start {
right = middle - 1
} else if ip > s.end {
left = middle + 1
}
}
return r
}
func (b *SinaIP) loadCountry(data []byte) error {
reader := bytes.NewReader(data)
var count uint16
if err := binary.Read(reader, binary.BigEndian, &count); err != nil {
return err
}
b.country = make(map[uint16]*Country, count)
for i := uint16(0); i < count; i++ {
var code uint16
if err := binary.Read(reader, binary.BigEndian, &code); err != nil {
return err
}
var length uint8
if err := binary.Read(reader, binary.BigEndian, &length); err != nil {
return err
}
country := make([]byte, length)
if _, err := io.ReadFull(reader, country); err != nil {
return err
}
b.country[code] = &Country{
name: string(country),
}
}
return nil
}
func (b *SinaIP) loadProvince(data []byte) error {
reader := bytes.NewReader(data)
var count uint16
if err := binary.Read(reader, binary.BigEndian, &count); err != nil {
return err
}
b.province = make(map[uint16]*Province, count)
for i := uint16(0); i < count; i++ {
var code uint16
if err := binary.Read(reader, binary.BigEndian, &code); err != nil {
return err
}
var length uint8
if err := binary.Read(reader, binary.BigEndian, &length); err != nil {
return err
}
province := make([]byte, length)
if _, err := io.ReadFull(reader, province); err != nil {
return err
}
b.province[code] = &Province{
name: string(province),
}
}
return nil
}
func (b *SinaIP) loadCity(data []byte) error {
reader := bytes.NewReader(data)
var count uint16
if err := binary.Read(reader, binary.BigEndian, &count); err != nil {
return err
}
b.city = make(map[uint16]*City, count)
for i := uint16(0); i < count; i++ {
var code uint16
if err := binary.Read(reader, binary.BigEndian, &code); err != nil {
return err
}
var length uint8
if err := binary.Read(reader, binary.BigEndian, &length); err != nil {
return err
}
city := make([]byte, length)
if _, err := io.ReadFull(reader, city); err != nil {
return err
}
b.city[code] = &City{
name: string(city),
}
}
return nil
}
func (b *SinaIP) loadISP(data []byte) error {
reader := bytes.NewReader(data)
var count uint16
if err := binary.Read(reader, binary.BigEndian, &count); err != nil {
return err
}
b.isp = make(map[uint16]*ISP, count)
for i := uint16(0); i < count; i++ {
var code uint16
if err := binary.Read(reader, binary.BigEndian, &code); err != nil {
return err
}
var length uint8
if err := binary.Read(reader, binary.BigEndian, &length); err != nil {
return err
}
isp := make([]byte, length)
if _, err := io.ReadFull(reader, isp); err != nil {
return err
}
b.isp[code] = &ISP{
name: string(isp),
}
}
return nil
}
func (b *SinaIP) loadDistrict(data []byte) error {
reader := bytes.NewReader(data)
var count uint16
if err := binary.Read(reader, binary.BigEndian, &count); err != nil {
return err
}
b.district = make(map[uint16]*District, count)
for i := uint16(0); i < count; i++ {
var code uint16
if err := binary.Read(reader, binary.BigEndian, &code); err != nil {
return err
}
var length uint8
if err := binary.Read(reader, binary.BigEndian, &length); err != nil {
return err
}
district := make([]byte, length)
if _, err := io.ReadFull(reader, district); err != nil {
return err
}
b.district[code] = &District{
name: string(district),
}
}
return nil
}
func (b *SinaIP) loadIPSegment(data []byte) error {
reader := bytes.NewReader(data)
var count uint32
if err := binary.Read(reader, binary.BigEndian, &count); err != nil {
return err
}
b.segment = make([]*IPSegment, 0, count)
for i := uint32(0); i < count; i++ {
segment := new(IPSegment)
if err := binary.Read(reader, binary.BigEndian, &segment.start); err != nil {
return err
}
if err := binary.Read(reader, binary.BigEndian, &segment.end); err != nil {
return err
}
var (
countryCode uint16
provinceCode uint16
cityCode uint16
ispCode uint16
districtCode uint16
latitude int32
longitude int32
)
if err := binary.Read(reader, binary.BigEndian, &countryCode); err != nil {
return err
} else {
segment.country = b.country[countryCode]
}
if err := binary.Read(reader, binary.BigEndian, &provinceCode); err != nil {
return err
} else {
segment.province = b.province[provinceCode]
}
if err := binary.Read(reader, binary.BigEndian, &cityCode); err != nil {
return err
} else {
segment.city = b.city[cityCode]
}
if err := binary.Read(reader, binary.BigEndian, &ispCode); err != nil {
return err
} else {
segment.isp = b.isp[ispCode]
}
if err := binary.Read(reader, binary.BigEndian, &districtCode); err != nil {
return err
} else {
segment.district = b.district[districtCode]
}
if err := binary.Read(reader, binary.BigEndian, &latitude); err != nil {
return err
} else {
segment.latitude = float64(latitude) / float64(10000)
}
if err := binary.Read(reader, binary.BigEndian, &longitude); err != nil {
return err
} else {
segment.longitude = float64(longitude) / float64(10000)
}
b.segment = append(b.segment, segment)
}
return nil
}

View File

@@ -0,0 +1,41 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_test",
"go_library",
)
go_test(
name = "go_default_test",
srcs = ["expr_test.go"],
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = [
"ast.go",
"check.go",
"eval.go",
"expr.go",
],
importpath = "go-common/app/service/live/broadcast-proxy/expr",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
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,289 @@
package expr
import (
"bytes"
"fmt"
"strconv"
"strings"
"text/scanner"
"unicode"
)
const (
TokenEOF = -(iota + 1)
TokenIdent
TokenInt
TokenFloat
TokenOperator
)
type lexer struct {
scan scanner.Scanner
token rune
text string
}
func (lex *lexer) getToken() rune {
return lex.token
}
func (lex *lexer) getText() string {
return lex.text
}
func (lex *lexer) next() {
token := lex.scan.Scan()
text := lex.scan.TokenText()
switch token {
case scanner.EOF:
lex.token = TokenEOF
lex.text = text
case scanner.Ident:
lex.token = TokenIdent
lex.text = text
case scanner.Int:
lex.token = TokenInt
lex.text = text
case scanner.Float:
lex.token = TokenFloat
lex.text = text
case '+', '-', '*', '/', '%', '~':
lex.token = TokenOperator
lex.text = text
case '&', '|', '=':
var buffer bytes.Buffer
lex.token = TokenOperator
buffer.WriteRune(token)
next := lex.scan.Peek()
if next == token {
buffer.WriteRune(next)
lex.scan.Scan()
}
lex.text = buffer.String()
case '>', '<', '!':
var buffer bytes.Buffer
lex.token = TokenOperator
buffer.WriteRune(token)
next := lex.scan.Peek()
if next == '=' {
buffer.WriteRune(next)
lex.scan.Scan()
}
lex.text = buffer.String()
default:
if token >= 0 {
lex.token = token
lex.text = text
} else {
msg := fmt.Sprintf("got unknown token:%q, text:%s", lex.token, lex.text)
panic(lexPanic(msg))
}
}
//fmt.Printf("token:%d, text:%s\n", lex.token, lex.text)
}
type lexPanic string
// describe returns a string describing the current token, for use in errors.
func (lex *lexer) describe() string {
switch lex.token {
case TokenEOF:
return "end of file"
case TokenIdent:
return fmt.Sprintf("identifier %s", lex.getText())
case TokenInt, TokenFloat:
return fmt.Sprintf("number %s", lex.getText())
}
return fmt.Sprintf("%q", rune(lex.getToken())) // any other rune
}
func precedence(token rune, text string) int {
if token == TokenOperator {
switch text {
case "~", "!":
return 9
case "*", "/", "%":
return 8
case "+", "-":
return 7
case ">", ">=", "<", "<=":
return 6
case "!=", "==", "=":
return 5
case "&":
return 4
case "|":
return 3
case "&&":
return 2
case "||":
return 1
default:
msg := fmt.Sprintf("unknown operator:%s", text)
panic(lexPanic(msg))
}
}
return 0
}
// ---- parser ----
type ExpressionParser struct {
expression Expr
variable map[string]struct{}
}
func NewExpressionParser() *ExpressionParser {
return &ExpressionParser{
expression: nil,
variable: make(map[string]struct{}),
}
}
// Parse parses the input string as an arithmetic expression.
//
// expr = num a literal number, e.g., 3.14159
// | id a variable name, e.g., x
// | id '(' expr ',' ... ')' a function call
// | '-' expr a unary operator ( + - ! )
// | expr '+' expr a binary operator ( + - * / && & || | == )
//
func (parser *ExpressionParser) Parse(input string) (err error) {
defer func() {
switch x := recover().(type) {
case nil:
// no panic
case lexPanic:
err = fmt.Errorf("%s", x)
default:
// unexpected panic: resume state of panic.
panic(x)
}
}()
lex := new(lexer)
lex.scan.Init(strings.NewReader(input))
lex.scan.Mode = scanner.ScanIdents | scanner.ScanInts | scanner.ScanFloats
lex.scan.IsIdentRune = parser.isIdentRune
lex.next() // initial lookahead
parser.expression = nil
parser.variable = make(map[string]struct{})
e := parser.parseExpr(lex)
if lex.token != scanner.EOF {
return fmt.Errorf("unexpected %s", lex.describe())
}
parser.expression = e
return nil
}
func (parser *ExpressionParser) GetExpr() Expr {
return parser.expression
}
func (parser *ExpressionParser) GetVariable() []string {
variable := make([]string, 0, len(parser.variable))
for v := range parser.variable {
if v != "true" && v != "false" {
variable = append(variable, v)
}
}
return variable
}
func (parser *ExpressionParser) isIdentRune(ch rune, i int) bool {
return ch == '$' || ch == '_' || unicode.IsLetter(ch) || unicode.IsDigit(ch) && i > 0
}
func (parser *ExpressionParser) parseExpr(lex *lexer) Expr {
return parser.parseBinary(lex, 1)
}
// binary = unary ('+' binary)*
// parseBinary stops when it encounters an
// operator of lower precedence than prec1.
func (parser *ExpressionParser) parseBinary(lex *lexer, prec1 int) Expr {
lhs := parser.parseUnary(lex)
for prec := precedence(lex.getToken(), lex.getText()); prec >= prec1; prec-- {
for precedence(lex.getToken(), lex.getText()) == prec {
op := lex.getText()
lex.next() // consume operator
rhs := parser.parseBinary(lex, prec+1)
lhs = binary{op, lhs, rhs}
}
}
return lhs
}
// unary = '+' expr | primary
func (parser *ExpressionParser) parseUnary(lex *lexer) Expr {
if lex.getToken() == TokenOperator {
op := lex.getText()
if op == "+" || op == "-" || op == "~" || op == "!" {
lex.next()
return unary{op, parser.parseUnary(lex)}
} else {
msg := fmt.Sprintf("unary got unknown operator:%s", lex.getText())
panic(lexPanic(msg))
}
}
return parser.parsePrimary(lex)
}
// primary = id
// | id '(' expr ',' ... ',' expr ')'
// | num
// | '(' expr ')'
func (parser *ExpressionParser) parsePrimary(lex *lexer) Expr {
switch lex.token {
case TokenIdent:
id := lex.getText()
lex.next()
if lex.token != '(' {
parser.variable[id] = struct{}{}
return Var(id)
}
lex.next() // consume '('
var args []Expr
if lex.token != ')' {
for {
args = append(args, parser.parseExpr(lex))
if lex.token != ',' {
break
}
lex.next() // consume ','
}
if lex.token != ')' {
msg := fmt.Sprintf("got %q, want ')'", lex.token)
panic(lexPanic(msg))
}
}
lex.next() // consume ')'
return call{id, args}
case TokenFloat:
f, err := strconv.ParseFloat(lex.getText(), 64)
if err != nil {
panic(lexPanic(err.Error()))
}
lex.next() // consume number
return literal{value: f}
case TokenInt:
i, err := strconv.ParseInt(lex.getText(), 10, 64)
if err != nil {
panic(lexPanic(err.Error()))
}
lex.next() // consume number
return literal{value: i}
case '(':
lex.next() // consume '('
e := parser.parseExpr(lex)
if lex.token != ')' {
msg := fmt.Sprintf("got %s, want ')'", lex.describe())
panic(lexPanic(msg))
}
lex.next() // consume ')'
return e
}
msg := fmt.Sprintf("unexpected %s", lex.describe())
panic(lexPanic(msg))
}

View File

@@ -0,0 +1,51 @@
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
package expr
import (
"fmt"
)
//!+Check
func (v Var) Check(vars map[Var]interface{}) error {
vars[v] = true
return nil
}
func (literal) Check(vars map[Var]interface{}) error {
return nil
}
func (u unary) Check(vars map[Var]interface{}) error {
return u.x.Check(vars)
}
func (b binary) Check(vars map[Var]interface{}) error {
if err := b.x.Check(vars); err != nil {
return err
}
return b.y.Check(vars)
}
func (c call) Check(vars map[Var]interface{}) error {
arity, ok := numParams[c.fn]
if !ok {
return fmt.Errorf("unknown function %q", c.fn)
}
if len(c.args) != arity {
return fmt.Errorf("call to %s has %d args, want %d",
c.fn, len(c.args), arity)
}
for _, arg := range c.args {
if err := arg.Check(vars); err != nil {
return err
}
}
return nil
}
var numParams = map[string]int{"pow": 2, "sin": 1, "sqrt": 1}
//!-Check

View File

@@ -0,0 +1,505 @@
package expr
import (
"fmt"
"math"
"reflect"
)
type Env map[Var]interface{}
type runtimePanic string
func SafetyEvalBool(expr Expr, env Env) (value bool, err error) {
defer func() {
switch x := recover().(type) {
case nil:
// no panic
case runtimePanic:
value = false
err = fmt.Errorf("%s", x)
default:
// unexpected panic: resume state of panic.
panic(x)
}
}()
if expr == nil {
return false, nil
}
value = ConvertToBool(expr.Eval(env))
return
}
func (v Var) Eval(env Env) reflect.Value {
switch v {
case "true":
return reflect.ValueOf(true)
case "false":
return reflect.ValueOf(false)
default:
if i, ok := env[v]; ok {
return reflect.ValueOf(i)
}
panic(runtimePanic(fmt.Sprintf("undefined variable: %s", v)))
}
}
func (l literal) Eval(_ Env) reflect.Value {
return reflect.ValueOf(l.value)
}
func (u unary) Eval(env Env) reflect.Value {
switch u.op {
case "+":
return unaryPlus(u.x.Eval(env))
case "-":
return unaryMinus(u.x.Eval(env))
case "!":
return logicalNegation(u.x.Eval(env))
case "~":
return bitwiseComplement(u.x.Eval(env))
}
panic(runtimePanic(fmt.Sprintf("unsupported unary operator: %q", u.op)))
}
func (b binary) Eval(env Env) reflect.Value {
switch b.op {
case "+":
return addition(b.x.Eval(env), b.y.Eval(env))
case "-":
return subtraction(b.x.Eval(env), b.y.Eval(env))
case "*":
return multiplication(b.x.Eval(env), b.y.Eval(env))
case "/":
return division(b.x.Eval(env), b.y.Eval(env))
case "%":
return modulus(b.x.Eval(env), b.y.Eval(env))
case "&":
return bitwiseAnd(b.x.Eval(env), b.y.Eval(env))
case "&&":
return logicalAnd(b.x.Eval(env), b.y.Eval(env))
case "|":
return bitwiseOr(b.x.Eval(env), b.y.Eval(env))
case "||":
return logicalOr(b.x.Eval(env), b.y.Eval(env))
case "=", "==":
return comparisonEqual(b.x.Eval(env), b.y.Eval(env))
case ">":
return comparisonGreater(b.x.Eval(env), b.y.Eval(env))
case ">=":
return comparisonGreaterOrEqual(b.x.Eval(env), b.y.Eval(env))
case "<":
return comparisonLess(b.x.Eval(env), b.y.Eval(env))
case "<=":
return comparisonLessOrEqual(b.x.Eval(env), b.y.Eval(env))
case "!=":
return comparisonNotEqual(b.x.Eval(env), b.y.Eval(env))
}
panic(runtimePanic(fmt.Sprintf("unsupported binary operator: %q", b.op)))
}
func (c call) Eval(env Env) reflect.Value {
switch c.fn {
case "pow":
return reflect.ValueOf(math.Pow(ConvertToFloat(c.args[0].Eval(env)), ConvertToFloat(c.args[1].Eval(env))))
case "sin":
return reflect.ValueOf(math.Sin(ConvertToFloat(c.args[0].Eval(env))))
case "sqrt":
return reflect.ValueOf(math.Sqrt(ConvertToFloat(c.args[0].Eval(env))))
}
panic(runtimePanic(fmt.Sprintf("unsupported function call: %s", c.fn)))
}
func ConvertToBool(v reflect.Value) bool {
switch v.Kind() {
case reflect.Bool:
return v.Bool()
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return v.Int() != 0
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return v.Uint() != 0
case reflect.Float32, reflect.Float64:
return v.Float() != 0
default:
panic(runtimePanic(fmt.Sprintf("cannot convert data type: %s to bool", v.Kind().String())))
}
}
func ConvertToInt(v reflect.Value) int64 {
switch v.Kind() {
case reflect.Bool:
if v.Bool() {
return 1
} else {
return 0
}
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return v.Int()
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return int64(v.Uint())
case reflect.Float32, reflect.Float64:
return int64(v.Float())
default:
panic(runtimePanic(fmt.Sprintf("cannot convert data type: %s to int", v.Kind().String())))
}
}
func ConvertToUint(v reflect.Value) uint64 {
switch v.Kind() {
case reflect.Bool:
if v.Bool() {
return 1
} else {
return 0
}
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return uint64(v.Int())
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return v.Uint()
case reflect.Float32, reflect.Float64:
return uint64(v.Float())
default:
panic(runtimePanic(fmt.Sprintf("cannot convert data type: %s to uint", v.Kind().String())))
}
}
func ConvertToFloat(v reflect.Value) float64 {
switch v.Kind() {
case reflect.Bool:
if v.Bool() {
return 1
} else {
return 0
}
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return float64(v.Int())
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return float64(v.Uint())
case reflect.Float32, reflect.Float64:
return v.Float()
default:
panic(runtimePanic(fmt.Sprintf("cannot convert data type: %s to float", v.Kind().String())))
}
}
func unaryPlus(v reflect.Value) reflect.Value {
return v
}
func unaryMinus(v reflect.Value) reflect.Value {
switch v.Kind() {
case reflect.Bool:
return v
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return reflect.ValueOf(-v.Int())
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return reflect.ValueOf(-v.Uint())
case reflect.Float32, reflect.Float64:
return reflect.ValueOf(-v.Float())
default:
panic(runtimePanic(fmt.Sprintf("unary minus not support type: %s", v.Kind().String())))
}
}
func logicalNegation(v reflect.Value) reflect.Value {
return reflect.ValueOf(!ConvertToBool(v))
}
func bitwiseComplement(v reflect.Value) reflect.Value {
switch v.Kind() {
case reflect.Bool:
return reflect.ValueOf(!v.Bool())
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return reflect.ValueOf(^v.Int())
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return reflect.ValueOf(^v.Uint())
case reflect.Float32, reflect.Float64:
panic(runtimePanic("cannot eval ~ for float"))
default:
panic(runtimePanic(fmt.Sprintf("bitwise complement not support type: %s", v.Kind().String())))
}
}
func typeLevel(k reflect.Kind) int {
switch k {
case reflect.Float32, reflect.Float64:
return 4
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
return 3
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
return 2
case reflect.Bool:
return 1
default:
return 0
}
}
func typeAscend(a reflect.Kind, b reflect.Kind) reflect.Kind {
if typeLevel(a) >= typeLevel(b) {
return a
} else {
return b
}
}
func addition(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Float32, reflect.Float64:
r := ConvertToFloat(left) + ConvertToFloat(right)
return reflect.ValueOf(r)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) + ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) + ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToInt(left) + ConvertToInt(right)
return reflect.ValueOf(r != 0)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support addition", left.Kind().String(), right.Kind().String())))
}
}
func subtraction(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Float32, reflect.Float64:
r := ConvertToFloat(left) - ConvertToFloat(right)
return reflect.ValueOf(r)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) - ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) - ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToInt(left) - ConvertToInt(right)
return reflect.ValueOf(r != 0)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support subtraction", left.Kind().String(), right.Kind().String())))
}
}
func multiplication(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Float32, reflect.Float64:
r := ConvertToFloat(left) * ConvertToFloat(right)
return reflect.ValueOf(r)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) * ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) * ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToInt(left) * ConvertToInt(right)
return reflect.ValueOf(r != 0)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support multiplication", left.Kind().String(), right.Kind().String())))
}
}
func division(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Float32, reflect.Float64:
r := ConvertToFloat(left) / ConvertToFloat(right)
return reflect.ValueOf(r)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) / ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) / ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToInt(left) / ConvertToInt(right)
return reflect.ValueOf(r != 0)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support division", left.Kind().String(), right.Kind().String())))
}
}
func modulus(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) % ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) % ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToInt(left) % ConvertToInt(right)
return reflect.ValueOf(r != 0)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support division", left.Kind().String(), right.Kind().String())))
}
}
func bitwiseAnd(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) & ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) & ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToBool(left) && ConvertToBool(right)
return reflect.ValueOf(r)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support bitwise and", left.Kind().String(), right.Kind().String())))
}
}
func bitwiseOr(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) | ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) | ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToBool(left) || ConvertToBool(right)
return reflect.ValueOf(r)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support bitwise or", left.Kind().String(), right.Kind().String())))
}
}
func logicalAnd(left reflect.Value, right reflect.Value) reflect.Value {
r := ConvertToBool(left) && ConvertToBool(right)
return reflect.ValueOf(r)
}
func logicalOr(left reflect.Value, right reflect.Value) reflect.Value {
r := ConvertToBool(left) || ConvertToBool(right)
return reflect.ValueOf(r)
}
func comparisonEqual(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Float32, reflect.Float64:
r := ConvertToFloat(left) == ConvertToFloat(right)
return reflect.ValueOf(r)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) == ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) == ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToInt(left) == ConvertToInt(right)
return reflect.ValueOf(r)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support comparison equal", left.Kind().String(), right.Kind().String())))
}
}
func comparisonNotEqual(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Float32, reflect.Float64:
r := ConvertToFloat(left) != ConvertToFloat(right)
return reflect.ValueOf(r)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) != ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) != ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToInt(left) != ConvertToInt(right)
return reflect.ValueOf(r)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support comparison not equal", left.Kind().String(), right.Kind().String())))
}
}
func comparisonGreater(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Float32, reflect.Float64:
r := ConvertToFloat(left) > ConvertToFloat(right)
return reflect.ValueOf(r)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) > ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) > ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToInt(left) > ConvertToInt(right)
return reflect.ValueOf(r)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support comparison greater", left.Kind().String(), right.Kind().String())))
}
}
func comparisonGreaterOrEqual(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Float32, reflect.Float64:
r := ConvertToFloat(left) >= ConvertToFloat(right)
return reflect.ValueOf(r)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) >= ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) >= ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToInt(left) >= ConvertToInt(right)
return reflect.ValueOf(r)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support comparison greater or equal", left.Kind().String(), right.Kind().String())))
}
}
func comparisonLess(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Float32, reflect.Float64:
r := ConvertToFloat(left) < ConvertToFloat(right)
return reflect.ValueOf(r)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) < ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) < ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToInt(left) < ConvertToInt(right)
return reflect.ValueOf(r)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support comparison less", left.Kind().String(), right.Kind().String())))
}
}
func comparisonLessOrEqual(left reflect.Value, right reflect.Value) reflect.Value {
k := typeAscend(left.Kind(), right.Kind())
switch k {
case reflect.Float32, reflect.Float64:
r := ConvertToFloat(left) <= ConvertToFloat(right)
return reflect.ValueOf(r)
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
r := ConvertToUint(left) <= ConvertToUint(right)
return reflect.ValueOf(r)
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
r := ConvertToInt(left) <= ConvertToInt(right)
return reflect.ValueOf(r)
case reflect.Bool:
r := ConvertToInt(left) <= ConvertToInt(right)
return reflect.ValueOf(r)
default:
panic(runtimePanic(fmt.Sprintf("type %s and %s not support comparison less or equal", left.Kind().String(), right.Kind().String())))
}
}

View File

@@ -0,0 +1,37 @@
package expr
import "reflect"
// A Var identifies a variable, e.g., x.
type Var string
// A literal is a numeric constant, e.g., 3.141.
type literal struct {
value interface{}
}
// An Expr is an arithmetic expression.
type Expr interface {
// Eval returns the value of this Expr in the environment env.
Eval(env Env) reflect.Value
// Check reports errors in this Expr and adds its Vars to the set.
Check(vars map[Var]interface{}) error
}
// A unary represents a unary operator expression, e.g., -x.
type unary struct {
op string // one of '+', '-', '!', '~'
x Expr
}
// A binary represents a binary operator expression, e.g., x+y.
type binary struct {
op string
x, y Expr
}
// A call represents a function call expression, e.g., sin(x).
type call struct {
fn string // one of "pow", "sin", "sqrt"
args []Expr
}

View File

@@ -0,0 +1,49 @@
package expr
import (
"fmt"
"testing"
)
func TestExpr(t *testing.T) {
tests := []struct {
expr string
env Env
want string
}{
{"$1 > 80 && $2 <9", Env{"$1": 100, "$2": 2}, "true"},
{"$1 % 10", Env{"$1": 104, "$2": 2}, "4"},
{"pow(x, false) + pow(y, false)", Env{"x": 12, "y": 1}, "2"},
{"pow(x, 3) + pow(y, 3)", Env{"x": 9, "y": 10}, "1729"},
{"5.0 / 9 * (F - 32)", Env{"F": -40}, "-40"},
{"5.0 / 9 * (F - 32)", Env{"F": 32}, "0"},
{"5.0 / 9 * (F - 32)", Env{"F": 212}, "100"},
////!-Eval
//// additional tests that don't appear in the book
{"-1 + -x", Env{"x": 1}, "-2"},
{"-1 - x", Env{"x": 1}, "-2"},
{"a >= 10", Env{"a": 15}, "true"},
{"b >= sin(10) && a < 1", Env{"a": 9, "b": 10}, "false"},
{"!!!true", Env{"a": 9, "b": 10}, "false"},
//!+Eval
}
var prevExpr string
parser := NewExpressionParser()
for _, test := range tests {
// Print expr only when it changes.
if test.expr != prevExpr {
t.Logf("\n%s\n", test.expr)
prevExpr = test.expr
}
if err := parser.Parse(test.expr); err != nil {
t.Error(err) // parse error
continue
}
got := fmt.Sprintf("%v", parser.GetExpr().Eval(test.env))
t.Logf("\t%v => %s\n", test.env, got)
if got != test.want {
t.Errorf("%s.Eval() in %v = %q, want %q\n",
test.expr, test.env, got, test.want)
}
}
}

View File

@@ -0,0 +1,31 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"log.go",
"sven.go",
],
importpath = "go-common/app/service/live/broadcast-proxy/grocery",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
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,44 @@
# sven.go
可能是最最精简的配置中心 SDK 了,简单接入。
# 集成
```go
package main
import (
"nano-repo/grocery"
"log"
)
func main() {
sven, err := grocery.NewSvenClient("13586", "sh001", "dev",
"docker-1", "7c41388b593d562120bec1bcb355e538")
if err != nil {
panic(err)
}
//Get the latest configuration with Config method anytime
c := sven.Config()
log.Printf("Initial version:%d", c.Version)
log.Printf("Initial config :%v", c.Config)
go func(){
//Get configuration change event with ConfigNotify method
for config := range sven.ConfigNotify() {
log.Printf("New version:%d", config.Version)
log.Printf("New config: %v", config.Config)
}
}()
go func(){
for e := range sven.LogNotify() {
log.Printf("Sven log return, level:%v, message:%v", e.Level, e.Message)
}
}()
quit := make(chan struct{})
<- quit
}
```

View File

@@ -0,0 +1,34 @@
package grocery
type level int
const (
FINEST level = iota
FINE
DEBUG
TRACE
INFO
WARNING
ERROR
CRITICAL
)
var (
kLevelStrings = [...]string{"FINEST", "FINE", "DEBUG", "TRACE", "INFO", "WARNING", "ERROR", "CRITICAL"}
)
func (l level) String() string {
if l < 0 || int(l) > len(kLevelStrings) {
return "UNKNOWN"
}
return kLevelStrings[int(l)]
}
type LogRecord struct {
Level level // The log level
Message string // The log message
}
func (r *LogRecord) String() string {
return r.Message
}

View File

@@ -0,0 +1,314 @@
package grocery
import (
"context"
"encoding/json"
"errors"
"io/ioutil"
"net"
"net/http"
"os"
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
)
const (
kLogChanSize = 0xFF
kSvenCheckTimeout = time.Minute
kSvenGetTimeout = 30 * time.Second
kSvenHost = "http://config.bilibili.co"
kSvenCheckAPI = kSvenHost + "/config/v2/check"
kSvenGetAPI = kSvenHost + "/config/v2/get"
kDefaultHost = "invalid-host-name"
kDefaultIP = "127.0.0.1"
kCodeNotModified = -304
)
type SvenClient struct {
treeID string
zone string
env string
build string
token string
host string
ip string
config atomic.Value
log chan *LogRecord
notify chan *SvenConfig
changeSignal chan struct{}
httpClient *http.Client
ctx context.Context
cancel context.CancelFunc
closeSignal chan struct{}
configLoadWg sync.WaitGroup
configNotifyWg sync.WaitGroup
}
type SvenConfig struct {
Version int
Config map[string]string
}
func NewSvenClient(treeID string, zone string, env string, build string, token string) (*SvenClient, error) {
host, err := os.Hostname()
if err != nil {
host = kDefaultHost
}
ip := kDefaultIP
addr, err := net.InterfaceAddrs()
if err == nil {
for _, a := range addr {
if n, ok := a.(*net.IPNet); ok && !n.IP.IsLoopback() && n.IP.To4() != nil {
ip = n.IP.String()
}
}
}
c := &SvenClient{
treeID: treeID,
zone: zone,
env: env,
build: build,
token: token,
host: host,
ip: ip,
log: make(chan *LogRecord, kLogChanSize),
notify: make(chan *SvenConfig),
changeSignal: make(chan struct{}, 1),
httpClient: new(http.Client),
closeSignal: make(chan struct{}),
}
c.ctx, c.cancel = context.WithCancel(context.Background())
version, config, err := c.svenConfigSync()
if err != nil {
return nil, err
}
c.config.Store(&SvenConfig{
Version: version,
Config: config,
})
c.changeSignal <- struct{}{}
c.configLoadWg.Add(1)
go func() {
defer c.configLoadWg.Done()
c.configLoadProcess()
}()
c.configNotifyWg.Add(1)
go func() {
defer c.configNotifyWg.Done()
c.configNotifyProcess()
}()
return c, nil
}
func (c *SvenClient) Close() {
close(c.closeSignal)
c.cancel()
c.configLoadWg.Wait()
close(c.changeSignal)
c.configNotifyWg.Wait()
}
func (c *SvenClient) Config() *SvenConfig {
result := &SvenConfig{
Version: -1,
Config: make(map[string]string),
}
if config, ok := c.config.Load().(*SvenConfig); ok {
result.Version = config.Version
for k, v := range config.Config {
result.Config[k] = v
}
}
return result
}
func (c *SvenClient) ConfigNotify() <-chan *SvenConfig {
return c.notify
}
func (c *SvenClient) LogNotify() <-chan *LogRecord {
return c.log
}
func (c *SvenClient) configLoadProcess() {
for {
select {
case <-c.closeSignal:
return
default:
}
current, ok := c.config.Load().(*SvenConfig)
if !ok {
current = &SvenConfig{
Version: -1,
}
}
version, err := c.svenCheckVersion(current.Version)
//config not modified
if version == current.Version {
c.postLog(INFO, "config not modified")
continue
}
if err != nil {
c.postLog(ERROR, err.Error())
continue
}
if current.Version == version {
continue
}
config, err := c.svenGetConfig(version)
if err != nil {
c.postLog(ERROR, err.Error())
continue
}
c.config.Store(&SvenConfig{
Version: version,
Config: config,
})
select {
case c.changeSignal <- struct{}{}:
default:
}
}
}
func (c *SvenClient) configNotifyProcess() {
for range c.changeSignal {
select {
case <-c.closeSignal:
return
case c.notify <- c.Config():
}
}
}
func (c *SvenClient) postLog(lv level, msg string) {
select {
case c.log <- &LogRecord{Level: lv, Message: msg}:
default:
}
}
func (c *SvenClient) svenConfigSync() (int, map[string]string, error) {
version, err := c.svenCheckVersion(-1)
if err != nil {
return -1, nil, err
}
config, err := c.svenGetConfig(version)
if err != nil {
return -1, nil, err
}
return version, config, nil
}
func (c *SvenClient) svenCheckVersion(version int) (int, error) {
var err error
req, err := http.NewRequest("GET", kSvenCheckAPI, nil)
if err != nil {
return -1, err
}
q := req.URL.Query()
q.Add("build", c.build)
q.Add("hostname", c.host)
q.Add("ip", c.ip)
q.Add("service", strings.Join([]string{c.treeID, c.env, c.zone}, "_"))
q.Add("token", c.token)
q.Add("version", strconv.Itoa(version))
req.URL.RawQuery = q.Encode()
ctx, cancel := context.WithTimeout(c.ctx, kSvenCheckTimeout)
defer cancel()
req = req.WithContext(ctx)
resp, err := c.httpClient.Do(req)
if err != nil {
return -1, err
}
defer resp.Body.Close()
result, err := ioutil.ReadAll(resp.Body)
if err != nil {
return -1, err
}
var svenCheckRespBody struct {
Code int `json:"code"`
Message string `json:"message"`
Data struct {
Version int `json:"version"`
} `json:"data"`
}
if err = json.Unmarshal(result, &svenCheckRespBody); err != nil {
return -1, err
}
if svenCheckRespBody.Code != 0 {
if svenCheckRespBody.Code == kCodeNotModified {
return version, nil
}
return -1, errors.New(svenCheckRespBody.Message)
}
return svenCheckRespBody.Data.Version, nil
}
func (c *SvenClient) svenGetConfig(version int) (map[string]string, error) {
var err error
req, err := http.NewRequest("GET", kSvenGetAPI, nil)
if err != nil {
return nil, err
}
q := req.URL.Query()
q.Add("build", c.build)
q.Add("hostname", c.host)
q.Add("ip", c.ip)
q.Add("service", strings.Join([]string{c.treeID, c.env, c.zone}, "_"))
q.Add("token", c.token)
q.Add("version", strconv.Itoa(version))
req.URL.RawQuery = q.Encode()
ctx, cancel := context.WithTimeout(c.ctx, kSvenGetTimeout)
defer cancel()
req = req.WithContext(ctx)
resp, err := c.httpClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
result, err := ioutil.ReadAll(resp.Body)
if err != nil {
return nil, err
}
var svenGetRespBody struct {
Code int `json:"code"`
Message string `json:"message"`
TTL int `json:"ttl"`
Data struct {
Version int `json:"version"`
MD5 string `json:"md5"`
Content string `json:"content"`
} `json:"data"`
}
if err = json.Unmarshal(result, &svenGetRespBody); err != nil {
return nil, err
}
if svenGetRespBody.Code != 0 {
return nil, errors.New(svenGetRespBody.Message)
}
var configContent []struct {
Name string `json:"name"`
Config string `json:"config"`
}
if err = json.Unmarshal([]byte(svenGetRespBody.Data.Content), &configContent); err != nil {
return nil, err
}
config := make(map[string]string)
for _, c := range configContent {
config[c.Name] = strings.TrimSpace(c.Config)
}
return config, nil
}

View File

@@ -0,0 +1,41 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"dispatch.go",
"http.go",
"proxy.go",
"zk.go",
],
importpath = "go-common/app/service/live/broadcast-proxy/server",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/live/broadcast-proxy/conf:go_default_library",
"//app/service/live/broadcast-proxy/dispatch:go_default_library",
"//app/service/live/broadcast-proxy/grocery:go_default_library",
"//library/log:go_default_library",
"//vendor/github.com/ipipdotnet/ipdb-go:go_default_library",
"//vendor/github.com/samuel/go-zookeeper/zk: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,113 @@
package server
import (
"errors"
"fmt"
"github.com/ipipdotnet/ipdb-go"
"go-common/app/service/live/broadcast-proxy/conf"
"go-common/app/service/live/broadcast-proxy/dispatch"
"go-common/app/service/live/broadcast-proxy/grocery"
"go-common/library/log"
"sync"
)
type CometDispatcher struct {
sven *grocery.SvenClient
stopper chan struct{}
wg sync.WaitGroup
locker sync.RWMutex
ipDataV4 *ipdb.City
ipDataV6 *ipdb.City
matcher *dispatch.Matcher
config *conf.DispatchConfig
}
func NewCometDispatcher(ipipConfig *conf.IpipConfig,
dispatchConfig *conf.DispatchConfig, svenConfig *conf.SvenConfig) (*CometDispatcher, error) {
sven, err := grocery.NewSvenClient(svenConfig.TreeID, svenConfig.Zone, svenConfig.Env, svenConfig.Build,
svenConfig.Token)
if err != nil {
return nil, err
}
ipDataV4, err := ipdb.NewCity(ipipConfig.V4)
if err != nil {
return nil, err
}
ipDataV6, err := ipdb.NewCity(ipipConfig.V6)
if err != nil {
return nil, err
}
dispatcher := &CometDispatcher{
sven: sven,
stopper: make(chan struct{}),
ipDataV4: ipDataV4,
ipDataV6: ipDataV6,
config: dispatchConfig,
}
config := sven.Config()
if data, ok := config.Config[dispatchConfig.FileName]; ok {
dispatcher.updateDispatchConfig(data)
} else {
return nil, errors.New(fmt.Sprintf("cannot find %s in sven config", dispatchConfig.FileName))
}
dispatcher.wg.Add(1)
go func() {
defer dispatcher.wg.Done()
dispatcher.configWatcherProcess(dispatchConfig.FileName)
}()
return dispatcher, nil
}
func (dispatcher *CometDispatcher) Close() {
close(dispatcher.stopper)
dispatcher.wg.Wait()
dispatcher.sven.Close()
}
func (dispatcher *CometDispatcher) updateDispatchConfig(config string) error {
matcher, err := dispatch.NewMatcher([]byte(config), dispatcher.ipDataV4, dispatcher.ipDataV6, dispatcher.config)
if err != nil {
log.Error("parse rule config error:%v, data:%s", err, config)
return err
}
dispatcher.locker.Lock()
dispatcher.matcher = matcher
dispatcher.locker.Unlock()
log.Info("parse rule config ok, data:%s", config)
return nil
}
func (dispatcher *CometDispatcher) configWatcherProcess(filename string) {
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
for config := range dispatcher.sven.ConfigNotify() {
log.Info("[sven]New version:%d", config.Version)
log.Info("[sven]New config: %v", config.Config)
if data, ok := config.Config[filename]; ok {
dispatcher.updateDispatchConfig(data)
}
}
}()
wg.Add(1)
go func() {
defer wg.Done()
for e := range dispatcher.sven.LogNotify() {
log.Info("[sven]log level:%v, message:%v", e.Level, e.Message)
}
}()
wg.Wait()
}
func (dispatcher *CometDispatcher) Dispatch(ip string, uid int64) ([]string, []string) {
var matcher *dispatch.Matcher
dispatcher.locker.RLock()
matcher = dispatcher.matcher
dispatcher.locker.RUnlock()
if matcher == nil {
return []string{dispatcher.config.DefaultDomain}, []string{dispatcher.config.DefaultDomain}
}
return matcher.Dispatch(ip, uid)
}

View File

@@ -0,0 +1,166 @@
package server
import (
"context"
"encoding/json"
"go-common/library/log"
"io/ioutil"
"net/http"
"strconv"
"sync"
"time"
)
type BroadcastService struct {
wg sync.WaitGroup
server *http.Server
proxy *BroadcastProxy
dispatch *CometDispatcher
}
func NewBroadcastService(addr string, proxy *BroadcastProxy, dispatch *CometDispatcher) (*BroadcastService, error) {
service := &BroadcastService{
proxy: proxy,
dispatch: dispatch,
}
service.wg.Add(1)
go func() {
defer service.wg.Done()
service.httpServerProcess(addr)
}()
return service, nil
}
func (service *BroadcastService) Close() {
service.server.Shutdown(context.Background())
}
func (service *BroadcastService) httpServerProcess(addr string) {
mux := http.NewServeMux()
mux.HandleFunc("/", service.Proxy)
mux.HandleFunc("/monitor/ping", service.Ping)
mux.HandleFunc("/dm/x/internal/v1/dispatch", service.Dispatch)
mux.HandleFunc("/dm/x/internal/v1/set_angry_value", service.SetAngryValue)
service.server = &http.Server{Addr: addr, Handler: mux}
service.server.SetKeepAlivesEnabled(true)
if err := service.server.ListenAndServe(); err != nil {
if err != http.ErrServerClosed {
panic(err)
}
}
}
func writeJsonResult(w http.ResponseWriter, r *http.Request, begin time.Time, v interface{}) {
data, err := json.Marshal(v)
if err != nil {
log.Error("[Http] write result json.Marshal:%v error:%v", v, err)
return
}
if _, err := w.Write([]byte(data)); err != nil {
log.Error("[Http] write result socket error:%v", err)
return
}
end := time.Now()
log.Info("request %s, response:%s, time cost:%s", r.RequestURI, data, end.Sub(begin).String())
}
func (service *BroadcastService) Proxy(w http.ResponseWriter, r *http.Request) {
service.proxy.HandleRequest(w, r)
}
func (service *BroadcastService) Ping(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte("pong"))
}
func (service *BroadcastService) Dispatch(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" {
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
return
}
var result struct {
Code int `json:"code"`
Data struct {
DanmakuServer []string `json:"dm_server"`
DanmakuHost []string `json:"dm_host"`
} `json:"data"`
}
defer writeJsonResult(w, r, time.Now(), &result)
ip := r.URL.Query().Get("ip")
uid, _ := strconv.ParseInt(r.URL.Query().Get("uid"), 10, 64)
result.Code = 0
result.Data.DanmakuServer, result.Data.DanmakuHost = service.dispatch.Dispatch(ip, uid)
}
func (service *BroadcastService) SetAngryValue(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
requestBody, err := ioutil.ReadAll(r.Body)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
// 气人值的workaround
//go func() {
responseCollection, errCollection := service.proxy.RequestAllBackend(r.Method, "/dm/1/num/change", requestBody)
for i := range responseCollection {
if errCollection[i] != nil {
log.Error("SetAngryValue server:%d error:%+v", i, errCollection[i])
} else {
log.Info("SetAngryValue server:%d result:%s", i, responseCollection[i])
}
}
//}()
w.WriteHeader(http.StatusOK)
response, _ := json.Marshal(map[string]interface{}{"ret": 1})
w.Write(response)
return
}
func (service *BroadcastService) SetAngryValueV2(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
w.WriteHeader(http.StatusMethodNotAllowed)
return
}
requestBody, err := ioutil.ReadAll(r.Body)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
//go func() {
responseCollection, errCollection := service.proxy.RequestAllBackend(r.Method,
"/dm/x/internal/v2/set_angry_value", requestBody)
for i := range responseCollection {
if errCollection[i] != nil {
log.Error("SetAngryValueV2 server:%d error:%+v", i, errCollection[i])
w.WriteHeader(http.StatusServiceUnavailable)
response, _ := json.Marshal(map[string]interface{}{"code": -1, "msg": errCollection[i].Error()})
w.Write(response)
return
}
var result struct {
Code int `json:"code"`
Message string `json:"msg"`
}
if err := json.Unmarshal([]byte(responseCollection[i]), &result); err != nil {
log.Error("SetAngryValueV2 server:%d response:%s", i, responseCollection[i])
w.WriteHeader(http.StatusServiceUnavailable)
response, _ := json.Marshal(map[string]interface{}{"code": -2, "msg": responseCollection[i]})
w.Write(response)
return
}
if result.Code != 0 {
w.WriteHeader(http.StatusOK)
w.Write([]byte(responseCollection[i]))
return
}
}
//}()
w.WriteHeader(http.StatusOK)
response, _ := json.Marshal(map[string]interface{}{"code": 0})
w.Write(response)
return
}

View File

@@ -0,0 +1,201 @@
package server
import (
"bytes"
"context"
"errors"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"net/http/httptest"
"net/http/httputil"
"net/url"
"sync"
"sync/atomic"
"time"
"go-common/library/log"
)
type BroadcastProxy struct {
backend []string
probePath string
reverseProxy []*httputil.ReverseProxy
bestClientIndex int32
probeSample int
wg sync.WaitGroup
ctx context.Context
cancel context.CancelFunc
}
func NewBroadcastProxy(backend []string, probePath string, maxIdleConns int, probeSample int) (*BroadcastProxy, error) {
if len(backend) == 0 {
return nil, errors.New("Require at least one backend")
}
proxy := new(BroadcastProxy)
if probeSample > 0 {
proxy.probeSample = probeSample
} else {
proxy.probeSample = 1
}
for _, addr := range backend {
proxy.backend = append(proxy.backend, addr)
proxy.probePath = probePath
p := httputil.NewSingleHostReverseProxy(&url.URL{
Scheme: "http",
Host: addr,
})
p.Transport = &http.Transport{
DisableKeepAlives: false,
MaxIdleConns: maxIdleConns,
MaxIdleConnsPerHost: maxIdleConns,
}
proxy.reverseProxy = append(proxy.reverseProxy, p)
}
proxy.ctx, proxy.cancel = context.WithCancel(context.Background())
proxy.wg.Add(1)
go func() {
defer proxy.wg.Done()
proxy.mainProbeProcess()
}()
return proxy, nil
}
func (proxy *BroadcastProxy) Close() {
proxy.cancel()
proxy.wg.Wait()
}
func (proxy *BroadcastProxy) HandleRequest(w http.ResponseWriter, r *http.Request) {
t1 := time.Now()
i := atomic.LoadInt32(&proxy.bestClientIndex)
proxy.reverseProxy[i].ServeHTTP(w, r)
t2 := time.Now()
log.V(3).Info("proxy process req:%s,backend id:%d, timecost:%s", r.RequestURI, i, t2.Sub(t1).String())
}
func (proxy *BroadcastProxy) RequestAllBackend(method, uri string, requestBody []byte) ([]string, []error) {
responseCollection := make([]string, len(proxy.reverseProxy))
errCollection := make([]error, len(proxy.reverseProxy))
var wg sync.WaitGroup
for i := range proxy.reverseProxy {
wg.Add(1)
go func(index int) {
defer wg.Done()
req, err := http.NewRequest(method, uri, bytes.NewReader(requestBody))
if err != nil {
errCollection[index] = err
return
}
httpRecorder := httptest.NewRecorder()
proxy.reverseProxy[index].ServeHTTP(httpRecorder, req)
resp := httpRecorder.Result()
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
errCollection[index] = errors.New(fmt.Sprintf("http response:%s", resp.Status))
return
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
errCollection[index] = err
return
}
responseCollection[index] = string(body)
}(i)
}
wg.Wait()
return responseCollection, errCollection
}
func (proxy *BroadcastProxy) mainProbeProcess() {
var wg sync.WaitGroup
interval := make([]time.Duration, len(proxy.backend))
for {
fast := -1
for i, probe := range proxy.reverseProxy {
wg.Add(1)
go func(p *httputil.ReverseProxy, index int) {
defer wg.Done()
interval[index] = proxy.unitProbeProcess(p, index)
}(probe, i)
}
wg.Wait()
for i, v := range interval {
if fast < 0 {
fast = i
} else {
if v < interval[fast] {
fast = i
}
}
}
atomic.StoreInt32(&proxy.bestClientIndex, int32(fast))
log.Info("[probe result]best server id:%d,addr:%s", fast, proxy.backend[fast])
for i, d := range interval {
log.Info("[probe log]server id:%d,addr:%s,avg time cost:%fms", i, proxy.backend[i], 1000*d.Seconds())
}
select {
case <-time.After(time.Second):
case <-proxy.ctx.Done():
return
}
}
}
func (proxy *BroadcastProxy) unitProbeProcess(p *httputil.ReverseProxy, backendIndex int) time.Duration {
var (
wg sync.WaitGroup
duration int64
)
for i := 0; i < proxy.probeSample; i++ {
wg.Add(1)
go func() {
defer wg.Done()
timeout := time.Second
<-time.After(time.Duration(rand.Intn(proxy.probeSample)) * time.Millisecond)
if timeCost, err := proxy.checkMonitorPing(p, backendIndex, timeout); err == nil {
atomic.AddInt64(&duration, timeCost.Nanoseconds())
} else {
atomic.AddInt64(&duration, timeout.Nanoseconds())
}
}()
}
wg.Wait()
return time.Duration(duration/int64(proxy.probeSample)) * time.Nanosecond
}
func (proxy *BroadcastProxy) checkMonitorPing(p *httputil.ReverseProxy, backendIndex int, timeout time.Duration) (time.Duration, error) {
req, err := http.NewRequest("GET", proxy.probePath, nil)
if err != nil {
return timeout, err
}
ctx, cancel := context.WithTimeout(proxy.ctx, timeout)
defer cancel()
req = req.WithContext(ctx)
recorder := httptest.NewRecorder()
beginTime := time.Now()
p.ServeHTTP(recorder, req)
resp := recorder.Result()
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
log.Error("probe:server id:%d,addr:%s,send requset error:%s", backendIndex,
proxy.backend[backendIndex], resp.Status)
return timeout, errors.New("http response:" + resp.Status)
}
result, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Error("probe:server id:%d,addr:%s,read response error:%v", backendIndex,
proxy.backend[backendIndex], err)
return timeout, err
}
if !bytes.Equal(result, []byte("pong")) {
log.Error("probe:server id:%d,addr:%s,not match response:%s", backendIndex,
proxy.backend[backendIndex], result)
return timeout, err
}
endTime := time.Now()
return endTime.Sub(beginTime), nil
}

View File

@@ -0,0 +1,214 @@
package server
import (
"github.com/samuel/go-zookeeper/zk"
"go-common/library/log"
"strings"
"time"
)
type ZkClient struct {
conn *zk.Conn
address []string
timeout time.Duration
dialTime time.Time
closed bool
stopper chan struct{}
}
func NewZkClient(addrs []string, timeout time.Duration) (*ZkClient, error) {
if timeout <= 0 {
timeout = time.Second * 5
}
c := &ZkClient{
address: addrs,
timeout: timeout,
stopper: make(chan struct{}),
}
if err := c.Reset(); err != nil {
return nil, err
}
return c, nil
}
func (c *ZkClient) GetTimeout() time.Duration {
return c.timeout
}
func (c *ZkClient) RecursiveCreate(path string) error {
if path == "" || path == "/" {
return nil
}
if exists, _, err := c.conn.Exists(path); err != nil {
return err
} else if exists {
return nil
}
if err := c.RecursiveCreate(path[0:strings.LastIndex(path, "/")]); err != nil {
return err
}
_, err := c.conn.Create(path, []byte{}, 0, zk.WorldACL(zk.PermAll))
if err != nil && err != zk.ErrNodeExists {
return err
}
return nil
}
func (c *ZkClient) Reset() error {
c.dialTime = time.Now()
conn, events, err := zk.Connect(c.address, c.timeout)
if err != nil {
return err
}
if c.conn != nil {
c.conn.Close()
c.conn = nil
}
c.conn = conn
go func() {
for ev := range events {
if ev.Err == nil {
log.V(2).Info("[ZooKeeper]Event Info:%+v", ev)
} else {
log.Error("[ZooKeeper]Event Error:%+v", ev)
}
}
}()
return nil
}
func (c *ZkClient) CreateEphemeralNode(path string, node string, data []byte) (string, error) {
if err := c.RecursiveCreate(path); err != nil {
return "", err
}
nodePath := strings.Join([]string{path, node}, "/")
path, err := c.conn.Create(nodePath, data, zk.FlagEphemeral, zk.WorldACL(zk.PermAll))
return path, err
}
func (c *ZkClient) CreatePersistNode(path string, node string, data []byte) (string, error) {
if err := c.RecursiveCreate(path); err != nil {
return "", err
}
nodePath := strings.Join([]string{path, node}, "/")
path, err := c.conn.Create(nodePath, data, 0, zk.WorldACL(zk.PermAll))
return path, err
}
func (c *ZkClient) Exists(path string, node string) (bool, int32, error) {
fullPath := strings.Join([]string{path, node}, "/")
exists, stat, err := c.conn.Exists(fullPath)
return exists, stat.Version, err
}
func (c *ZkClient) SetNodeData(path string, node string, data []byte, version int32) error {
var err error
fullPath := strings.Join([]string{path, node}, "/")
_, err = c.conn.Set(fullPath, data, version)
return err
}
func (c *ZkClient) GetNodeData(path string, node string) ([]byte, int32, error) {
var err error
fullPath := strings.Join([]string{path, node}, "/")
data, stat, err := c.conn.Get(fullPath)
return data, stat.Version, err
}
func (c *ZkClient) DeleteNode(path string, node string) error {
var err error
fullPath := strings.Join([]string{path, node}, "/")
exists, stat, err := c.conn.Exists(fullPath)
if err != nil {
return err
}
if !exists {
return nil
}
err = c.conn.Delete(fullPath, stat.Version)
return err
}
func (c *ZkClient) Close() {
if c.closed {
return
}
c.closed = true
if c.conn != nil {
c.conn.Close()
}
close(c.stopper)
}
func (c *ZkClient) GetChildren(node string) ([]string, error) {
children, _, err := c.conn.Children(node)
return children, err
}
func (c *ZkClient) GetChildrenWithData(node string) (map[string]string, error) {
children, _, err := c.conn.Children(node)
result := make(map[string]string)
for _, child := range children {
if data, _, e := c.conn.Get(strings.Join([]string{node, child}, "/")); e == nil {
result[child] = string(data)
} else {
log.Error("[ZookeeperClient]GetChildrenWithData:get child:%s failed, err:%s", child, e.Error())
}
}
return result, err
}
func (c *ZkClient) GetData(path string) (string, error) {
data, _, err := c.conn.Get(path)
return string(data), err
}
func (c *ZkClient) WatchChildren(path string) (map[string]struct{}, <-chan zk.Event, error) {
if exists, _, err := c.conn.Exists(path); err != nil {
return nil, nil, err
} else if !exists {
return nil, nil, zk.ErrNoNode
}
children, _, event, err := c.conn.ChildrenW(path)
if err != nil {
return nil, nil, err
}
result := make(map[string]struct{})
for _, child := range children {
result[child] = struct{}{}
}
return result, event, nil
}
func (c *ZkClient) WatchChildrenWithData(node string) (map[string]string, <-chan zk.Event, error) {
if exists, _, err := c.conn.Exists(node); err != nil {
return nil, nil, err
} else if !exists {
return nil, nil, zk.ErrNoNode
}
children, _, event, err := c.conn.ChildrenW(node)
if err != nil {
return nil, nil, err
}
result := make(map[string]string)
for _, child := range children {
if data, _, e := c.conn.Get(strings.Join([]string{node, child}, "/")); e == nil {
result[child] = string(data)
} else {
return nil, nil, e
}
}
return result, event, nil
}
func (c *ZkClient) WatchData(path string) ([]byte, <-chan zk.Event, error) {
data, _, event, err := c.conn.GetW(path)
return data, event, err
}
func (c *ZkClient) ZooKeeperPath(args ...string) string {
return strings.Join(args, "/")
}

View File

@@ -0,0 +1,39 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["grpc.go"],
importpath = "go-common/app/service/live/broadcast-proxy/service",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/live/broadcast-proxy/api/v1:go_default_library",
"//app/service/live/broadcast-proxy/server:go_default_library",
"//app/service/live/broadcast-proxy/service/v1:go_default_library",
"//library/net/rpc/warden:go_default_library",
"//library/time:go_default_library",
"@org_golang_google_grpc//:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/broadcast-proxy/service/v1:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,27 @@
package service
import (
"errors"
v1pb "go-common/app/service/live/broadcast-proxy/api/v1"
"go-common/app/service/live/broadcast-proxy/server"
v1srv "go-common/app/service/live/broadcast-proxy/service/v1"
"go-common/library/net/rpc/warden"
xtime "go-common/library/time"
"google.golang.org/grpc"
"time"
)
func NewGrpcService(p *server.BroadcastProxy, d *server.CometDispatcher) (*warden.Server, error) {
if p == nil || d == nil {
return nil, errors.New("empty proxy")
}
ws := warden.NewServer(&warden.ServerConfig{
Timeout: xtime.Duration(30 * time.Second),
}, grpc.MaxRecvMsgSize(1024 * 1024 * 1024), grpc.MaxSendMsgSize(1024 * 1024 * 1024))
v1pb.RegisterDanmakuServer(ws.Server(), v1srv.NewDanmakuService(p, d))
ws, err := ws.Start()
if err != nil {
return nil, err
}
return ws, nil
}

View File

@@ -0,0 +1,34 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["danmaku.go"],
importpath = "go-common/app/service/live/broadcast-proxy/service/v1",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/live/broadcast-proxy/api/v1:go_default_library",
"//app/service/live/broadcast-proxy/server:go_default_library",
"//library/ecode:go_default_library",
"//library/log: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,410 @@
package v1
import (
"bytes"
"compress/gzip"
"context"
"encoding/gob"
"encoding/json"
v1pb "go-common/app/service/live/broadcast-proxy/api/v1"
"go-common/app/service/live/broadcast-proxy/server"
"go-common/library/ecode"
"go-common/library/log"
"io/ioutil"
"net/http"
"net/http/httptest"
"strconv"
"strings"
"time"
)
const (
kRequestIsNil = "request is nil"
)
// DanmakuService struct
type DanmakuService struct {
proxy *server.BroadcastProxy
dispatcher *server.CometDispatcher
}
//NewDanmakuService init
func NewDanmakuService(p *server.BroadcastProxy, d *server.CometDispatcher) (s *DanmakuService) {
s = &DanmakuService{
proxy: p,
dispatcher: d,
}
return s
}
func (s *DanmakuService) writeLog(method string, begin time.Time, req interface{}, resp interface{}) {
end := time.Now()
log.Info("method %s, request:%v, response:%v, time cost:%s", method, req, resp, end.Sub(begin).String())
}
// RoomMessage implementation
func (s *DanmakuService) RoomMessage(ctx context.Context, req *v1pb.RoomMessageRequest) (resp *v1pb.GeneralResponse, err error) {
resp = &v1pb.GeneralResponse{}
if req == nil {
return resp, ecode.Error(-1, kRequestIsNil)
}
httpRequest, err := http.NewRequest("POST", "/dm/1/push", strings.NewReader(req.Message))
if err != nil {
return resp, ecode.Error(-2, err.Error())
}
//httpRequest = httpRequest.WithContext(ctx)
q := httpRequest.URL.Query()
q.Add("cid", strconv.FormatInt(int64(req.RoomId), 10))
q.Add("ensure", strconv.FormatInt(int64(req.Ensure), 10))
httpRequest.URL.RawQuery = q.Encode()
httpRecorder := httptest.NewRecorder()
s.proxy.HandleRequest(httpRecorder, httpRequest)
httpResponse := httpRecorder.Result()
defer httpResponse.Body.Close()
if httpResponse.StatusCode != http.StatusOK {
return resp, ecode.Errorf(-3, "remote http response code:%s", httpResponse.Status)
}
result, err := ioutil.ReadAll(httpResponse.Body)
if err != nil {
return resp, ecode.Error(-4, err.Error())
}
var jsonRespBody struct {
Code int `json:"ret"`
}
if err = json.Unmarshal(result, &jsonRespBody); err != nil {
return resp, ecode.Error(-5, err.Error())
}
if jsonRespBody.Code != 1 {
return resp, ecode.Error(-6, "internal server error")
}
return resp, nil
}
// BroadcastMessage implementation
func (s *DanmakuService) BroadcastMessage(ctx context.Context, req *v1pb.BroadcastMessageRequest) (resp *v1pb.GeneralResponse, err error) {
resp = &v1pb.GeneralResponse{}
if req == nil {
return resp, ecode.Error(-1, kRequestIsNil)
}
httpRequest, err := http.NewRequest("POST", "/dm/1/push/all", strings.NewReader(req.Message))
if err != nil {
return resp, ecode.Error(-2, err.Error())
}
var exclude strings.Builder
if len(req.ExcludeRoomId) > 0 {
exclude.WriteString(strconv.FormatInt(int64(req.ExcludeRoomId[0]), 10))
}
if len(req.ExcludeRoomId) > 1 {
for _, excludeRoom := range req.ExcludeRoomId[1:] {
exclude.WriteByte(',')
exclude.WriteString(strconv.FormatInt(int64(excludeRoom), 10))
}
}
//httpRequest = httpRequest.WithContext(ctx)
q := httpRequest.URL.Query()
q.Add("exclude_room", exclude.String())
httpRequest.URL.RawQuery = q.Encode()
httpRecorder := httptest.NewRecorder()
s.proxy.HandleRequest(httpRecorder, httpRequest)
httpResponse := httpRecorder.Result()
defer httpResponse.Body.Close()
if httpResponse.StatusCode != http.StatusOK {
return resp, ecode.Errorf(-5, "remote http response code:%s", httpResponse.Status)
}
result, err := ioutil.ReadAll(httpResponse.Body)
if err != nil {
return resp, ecode.Error(-3, err.Error())
}
var jsonRespBody struct {
Code int `json:"ret"`
}
if err = json.Unmarshal(result, &jsonRespBody); err != nil {
return resp, ecode.Error(-5, err.Error())
}
if jsonRespBody.Code != 1 {
return resp, ecode.Error(-4, "internal server error")
}
return resp, nil
}
// MultiRoomMessage implementation
func (s *DanmakuService) MultiRoomMessage(ctx context.Context, req *v1pb.MultiRoomMessageRequest) (resp *v1pb.GeneralResponse, err error) {
resp = &v1pb.GeneralResponse{}
if req == nil {
return resp, ecode.Error(-1, kRequestIsNil)
}
jsonRequestData, err := json.Marshal(req)
if err != nil {
return resp, ecode.Error(-2, err.Error())
}
var httpRequestBuffer bytes.Buffer
gzipWriter, err := gzip.NewWriterLevel(&httpRequestBuffer, gzip.BestCompression)
if err != nil {
return resp, ecode.Error(-3, err.Error())
}
gzipWriter.Write(jsonRequestData)
gzipWriter.Close()
httpRequest, err := http.NewRequest("POST", "/dm/v1/push/multi_room", &httpRequestBuffer)
if err != nil {
return resp, ecode.Error(-4, err.Error())
}
httpRecorder := httptest.NewRecorder()
s.proxy.HandleRequest(httpRecorder, httpRequest)
httpResponse := httpRecorder.Result()
defer httpResponse.Body.Close()
if httpResponse.StatusCode != http.StatusOK {
return resp, ecode.Errorf(-7, "remote http response code:%s", httpResponse.Status)
}
result, err := ioutil.ReadAll(httpResponse.Body)
if err != nil {
return resp, ecode.Error(-5, err.Error())
}
var jsonRespBody struct {
Code int `json:"code"`
Message string `json:"msg"`
}
if err = json.Unmarshal(result, &jsonRespBody); err != nil {
return resp, ecode.Error(-6, err.Error())
}
if jsonRespBody.Code != 0 {
return resp, ecode.Error(ecode.Code(jsonRespBody.Code), jsonRespBody.Message)
}
return resp, nil
}
// BatchRoomMessage implementation
func (s *DanmakuService) BatchRoomMessage(ctx context.Context, req *v1pb.BatchRoomMessageRequest) (resp *v1pb.GeneralResponse, err error) {
resp = &v1pb.GeneralResponse{}
if req == nil {
return resp, ecode.Error(-1, kRequestIsNil)
}
jsonRequestData, err := json.Marshal(req)
if err != nil {
return resp, ecode.Error(-2, err.Error())
}
var httpRequestBuffer bytes.Buffer
gzipWriter, err := gzip.NewWriterLevel(&httpRequestBuffer, gzip.BestCompression)
if err != nil {
return resp, ecode.Error(-3, err.Error())
}
gzipWriter.Write(jsonRequestData)
gzipWriter.Close()
httpRequest, err := http.NewRequest("POST", "/dm/v1/push/multi_msg", &httpRequestBuffer)
if err != nil {
return resp, ecode.Error(-4, err.Error())
}
httpRecorder := httptest.NewRecorder()
s.proxy.HandleRequest(httpRecorder, httpRequest)
httpResponse := httpRecorder.Result()
defer httpResponse.Body.Close()
if httpResponse.StatusCode != http.StatusOK {
return resp, ecode.Errorf(-7, "remote http response code:%s", httpResponse.Status)
}
result, err := ioutil.ReadAll(httpResponse.Body)
if err != nil {
return resp, ecode.Error(-5, err.Error())
}
var jsonRespBody struct {
Code int `json:"code"`
Message string `json:"msg"`
}
if err = json.Unmarshal(result, &jsonRespBody); err != nil {
return resp, ecode.Error(-6, err.Error())
}
if jsonRespBody.Code != 0 {
return resp, ecode.Error(ecode.Code(jsonRespBody.Code), jsonRespBody.Message)
}
return resp, nil
}
// UserMessage implementation
func (s *DanmakuService) UserMessage(ctx context.Context, req *v1pb.UserMessageRequest) (resp *v1pb.GeneralResponse, err error) {
resp = &v1pb.GeneralResponse{}
if req == nil {
return resp, ecode.Error(-1, kRequestIsNil)
}
httpRequest, err := http.NewRequest("POST", "/dm/v1/push/user_msg", strings.NewReader(req.Message))
if err != nil {
return resp, ecode.Error(-2, err.Error())
}
//httpRequest = httpRequest.WithContext(ctx)
q := httpRequest.URL.Query()
q.Add("uid", strconv.FormatInt(int64(req.UserId), 10))
httpRequest.URL.RawQuery = q.Encode()
httpRecorder := httptest.NewRecorder()
s.proxy.HandleRequest(httpRecorder, httpRequest)
httpResponse := httpRecorder.Result()
defer httpResponse.Body.Close()
if httpResponse.StatusCode != http.StatusOK {
return resp, ecode.Errorf(-7, "remote http response code:%s", httpResponse.Status)
}
result, err := ioutil.ReadAll(httpResponse.Body)
if err != nil {
return resp, ecode.Error(-3, err.Error())
}
var jsonRespBody struct {
Code int `json:"code"`
Message string `json:"msg"`
}
if err = json.Unmarshal(result, &jsonRespBody); err != nil {
return resp, ecode.Error(-4, err.Error())
}
if jsonRespBody.Code != 0 {
return resp, ecode.Error(ecode.Code(jsonRespBody.Code), jsonRespBody.Message)
}
return resp, nil
}
// BatchUserMessage implementation
func (s *DanmakuService) BatchUserMessage(ctx context.Context, req *v1pb.BatchUserMessageRequest) (resp *v1pb.GeneralResponse, err error) {
resp = &v1pb.GeneralResponse{}
if req == nil {
return resp, ecode.Error(-1, kRequestIsNil)
}
jsonRequestData, err := json.Marshal(req)
if err != nil {
return resp, ecode.Error(-2, err.Error())
}
var httpRequestBuffer bytes.Buffer
gzipWriter, err := gzip.NewWriterLevel(&httpRequestBuffer, gzip.BestCompression)
if err != nil {
return resp, ecode.Error(-3, err.Error())
}
gzipWriter.Write(jsonRequestData)
gzipWriter.Close()
httpRequest, err := http.NewRequest("POST", "/dm/v1/push/multi_user_msg", &httpRequestBuffer)
if err != nil {
return resp, ecode.Error(-4, err.Error())
}
httpRecorder := httptest.NewRecorder()
s.proxy.HandleRequest(httpRecorder, httpRequest)
httpResponse := httpRecorder.Result()
defer httpResponse.Body.Close()
if httpResponse.StatusCode != http.StatusOK {
return resp, ecode.Errorf(-7, "remote http response code:%s", httpResponse.Status)
}
result, err := ioutil.ReadAll(httpResponse.Body)
if err != nil {
return resp, ecode.Error(-5, err.Error())
}
var jsonRespBody struct {
Code int `json:"code"`
Message string `json:"msg"`
}
if err = json.Unmarshal(result, &jsonRespBody); err != nil {
return resp, ecode.Error(-6, err.Error())
}
if jsonRespBody.Code != 0 {
return resp, ecode.Error(ecode.Code(jsonRespBody.Code), jsonRespBody.Message)
}
return resp, nil
}
// Dispatch implementation
func (s *DanmakuService) Dispatch(ctx context.Context, req *v1pb.DispatchRequest) (resp *v1pb.DispatchResponse, err error) {
resp = &v1pb.DispatchResponse{}
if req == nil {
return resp, ecode.Error(-1, kRequestIsNil)
}
defer s.writeLog("Dispatch", time.Now(), req, resp)
ip, host := s.dispatcher.Dispatch(req.UserIp, req.UserId)
resp.Host = host
resp.Ip = ip
return resp, nil
}
func (s *DanmakuService) SetAngryValue(ctx context.Context, req *v1pb.SetAngryValueRequest) (resp *v1pb.SetAngryValueResponse, err error) {
resp = &v1pb.SetAngryValueResponse{}
if req == nil {
return resp, ecode.Error(-1, kRequestIsNil)
}
defer s.writeLog("SetAngryValue", time.Now(), req, resp)
if len(req.AngryValue) == 0 {
return resp, ecode.Error(-2, "empty angry value")
}
var rawAngryValueBuffer bytes.Buffer
enc := gob.NewEncoder(&rawAngryValueBuffer)
if err = enc.Encode(req.AngryValue); err != nil {
return resp, ecode.Error(-3, err.Error())
}
var httpRequestBuffer bytes.Buffer
gzipWriter, _ := gzip.NewWriterLevel(&httpRequestBuffer, gzip.BestCompression)
gzipWriter.Write(rawAngryValueBuffer.Bytes())
gzipWriter.Close()
httpRequest, err := http.NewRequest("POST", "/dm/x/internal/v2/set_angry_value", &httpRequestBuffer)
if err != nil {
return resp, ecode.Error(-4, err.Error())
}
httpRecorder := httptest.NewRecorder()
s.proxy.HandleRequest(httpRecorder, httpRequest)
httpResponse := httpRecorder.Result()
defer httpResponse.Body.Close()
if httpResponse.StatusCode != http.StatusOK {
return resp, ecode.Errorf(-5, "remote http response code:%s", httpResponse.Status)
}
result, err := ioutil.ReadAll(httpResponse.Body)
if err != nil {
return resp, ecode.Error(-6, err.Error())
}
var jsonRespBody struct {
Code int `json:"code"`
Message string `json:"msg"`
}
if err = json.Unmarshal(result, &jsonRespBody); err != nil {
return resp, ecode.Error(-7, err.Error())
}
if jsonRespBody.Code != 0 {
return resp, ecode.Error(ecode.Code(jsonRespBody.Code), jsonRespBody.Message)
}
return resp, nil
}
func (s *DanmakuService) GetRoomOnlineCount(ctx context.Context, req *v1pb.GetRoomOnlineCountRequest) (resp *v1pb.GetRoomOnlineCountResponse, err error) {
resp = &v1pb.GetRoomOnlineCountResponse{}
if req == nil {
return resp, ecode.Error(-1, kRequestIsNil)
}
defer s.writeLog("GetRoomOnlineCount", time.Now(), req, resp)
if len(req.RoomId) == 0 {
return resp, ecode.Error(-2, "empty angry value")
}
var rawRoomIdBuffer bytes.Buffer
enc := gob.NewEncoder(&rawRoomIdBuffer)
if err = enc.Encode(req.RoomId); err != nil {
return resp, ecode.Error(-3, err.Error())
}
var httpRequestBuffer bytes.Buffer
gzipWriter, _ := gzip.NewWriterLevel(&httpRequestBuffer, gzip.BestCompression)
gzipWriter.Write(rawRoomIdBuffer.Bytes())
gzipWriter.Close()
httpRequest, err := http.NewRequest("POST", "/dm/x/internal/v3/get_room_online_count", &httpRequestBuffer)
if err != nil {
return resp, ecode.Error(-2, err.Error())
}
httpRecorder := httptest.NewRecorder()
s.proxy.HandleRequest(httpRecorder, httpRequest)
httpResponse := httpRecorder.Result()
defer httpResponse.Body.Close()
if httpResponse.StatusCode != http.StatusOK {
return resp, ecode.Errorf(-3, "remote http response code:%s", httpResponse.Status)
}
reader, err := gzip.NewReader(httpResponse.Body)
if err != nil {
return resp, ecode.Error(-4, err.Error())
}
defer reader.Close()
dec := gob.NewDecoder(reader)
var resultData struct {
Code int
Message string
Data map[uint64]uint64
}
if err = dec.Decode(&resultData); err != nil {
return resp, ecode.Error(-5, err.Error())
}
if resultData.Code != 0 {
return resp, ecode.Error(ecode.Code(resultData.Code), resultData.Message)
}
resp.RoomOnlineCount = resultData.Data
return resp, nil
}

View File

@@ -0,0 +1,16 @@
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/captcha/api/liverpc:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

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/app/service/live/captcha/api/liverpc",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/live/captcha/api/liverpc/v0:go_default_library",
"//app/service/live/captcha/api/liverpc/v1:go_default_library",
"//library/net/rpc/liverpc:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/live/captcha/api/liverpc/v0:all-srcs",
"//app/service/live/captcha/api/liverpc/v1: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 liverpc
import (
"go-common/app/service/live/captcha/api/liverpc/v0"
"go-common/app/service/live/captcha/api/liverpc/v1"
"go-common/library/net/rpc/liverpc"
)
// Client that represents a liverpc captcha service api
type Client struct {
cli *liverpc.Client
// V0Captcha presents the controller in liverpc
V0Captcha v0.CaptchaRPCClient
// V1Captcha presents the controller in liverpc
V1Captcha v1.CaptchaRPCClient
}
// DiscoveryAppId the discovery id is not the tree name
var DiscoveryAppId = "live.captcha"
// New a Client that represents a liverpc live.captcha 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.V0Captcha = v0.NewCaptchaRPCClient(realCli)
cli.V1Captcha = v1.NewCaptchaRPCClient(realCli)
}

View File

@@ -0,0 +1,56 @@
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 = "v0_proto",
srcs = ["Captcha.proto"],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "v0_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/service/live/captcha/api/liverpc/v0",
proto = ":v0_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = ["Captcha.liverpc.go"],
embed = [":v0_go_proto"],
importpath = "go-common/app/service/live/captcha/api/liverpc/v0",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/liverpc:go_default_library",
"@com_github_gogo_protobuf//gogoproto: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: v0/Captcha.proto
/*
Package v0 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:
v0/Captcha.proto
*/
package v0
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:
// =================
// Captcha Interface
// =================
type CaptchaRPCClient interface {
// * 校验验证码
//
Check(ctx context.Context, req *CaptchaCheckReq, opts ...liverpc.CallOption) (resp *CaptchaCheckResp, err error)
}
// =======================
// Captcha Live Rpc Client
// =======================
type captchaRPCClient struct {
client *liverpc.Client
}
// NewCaptchaRPCClient creates a client that implements the CaptchaRPCClient interface.
func NewCaptchaRPCClient(client *liverpc.Client) CaptchaRPCClient {
return &captchaRPCClient{
client: client,
}
}
func (c *captchaRPCClient) Check(ctx context.Context, in *CaptchaCheckReq, opts ...liverpc.CallOption) (*CaptchaCheckResp, error) {
out := new(CaptchaCheckResp)
err := doRPCRequest(ctx, c.client, 0, "Captcha.check", 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
}

View File

@@ -0,0 +1,715 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: v0/Captcha.proto
package v0
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type CaptchaCheckReq struct {
// token值
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token"`
// 输入值
Phrase string `protobuf:"bytes,2,opt,name=phrase,proto3" json:"phrase"`
}
func (m *CaptchaCheckReq) Reset() { *m = CaptchaCheckReq{} }
func (m *CaptchaCheckReq) String() string { return proto.CompactTextString(m) }
func (*CaptchaCheckReq) ProtoMessage() {}
func (*CaptchaCheckReq) Descriptor() ([]byte, []int) {
return fileDescriptor_Captcha_715baa8051ae2c15, []int{0}
}
func (m *CaptchaCheckReq) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CaptchaCheckReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CaptchaCheckReq.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *CaptchaCheckReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_CaptchaCheckReq.Merge(dst, src)
}
func (m *CaptchaCheckReq) XXX_Size() int {
return m.Size()
}
func (m *CaptchaCheckReq) XXX_DiscardUnknown() {
xxx_messageInfo_CaptchaCheckReq.DiscardUnknown(m)
}
var xxx_messageInfo_CaptchaCheckReq proto.InternalMessageInfo
func (m *CaptchaCheckReq) GetToken() string {
if m != nil {
return m.Token
}
return ""
}
func (m *CaptchaCheckReq) GetPhrase() string {
if m != nil {
return m.Phrase
}
return ""
}
type CaptchaCheckResp struct {
// code
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code"`
// msg
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"`
//
Data map[int64]int64 `protobuf:"bytes,3,rep,name=data" json:"data" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
}
func (m *CaptchaCheckResp) Reset() { *m = CaptchaCheckResp{} }
func (m *CaptchaCheckResp) String() string { return proto.CompactTextString(m) }
func (*CaptchaCheckResp) ProtoMessage() {}
func (*CaptchaCheckResp) Descriptor() ([]byte, []int) {
return fileDescriptor_Captcha_715baa8051ae2c15, []int{1}
}
func (m *CaptchaCheckResp) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CaptchaCheckResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CaptchaCheckResp.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *CaptchaCheckResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_CaptchaCheckResp.Merge(dst, src)
}
func (m *CaptchaCheckResp) XXX_Size() int {
return m.Size()
}
func (m *CaptchaCheckResp) XXX_DiscardUnknown() {
xxx_messageInfo_CaptchaCheckResp.DiscardUnknown(m)
}
var xxx_messageInfo_CaptchaCheckResp proto.InternalMessageInfo
func (m *CaptchaCheckResp) GetCode() int64 {
if m != nil {
return m.Code
}
return 0
}
func (m *CaptchaCheckResp) GetMsg() string {
if m != nil {
return m.Msg
}
return ""
}
func (m *CaptchaCheckResp) GetData() map[int64]int64 {
if m != nil {
return m.Data
}
return nil
}
func init() {
proto.RegisterType((*CaptchaCheckReq)(nil), "captcha.v0.CaptchaCheckReq")
proto.RegisterType((*CaptchaCheckResp)(nil), "captcha.v0.CaptchaCheckResp")
proto.RegisterMapType((map[int64]int64)(nil), "captcha.v0.CaptchaCheckResp.DataEntry")
}
func (m *CaptchaCheckReq) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *CaptchaCheckReq) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.Token) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintCaptcha(dAtA, i, uint64(len(m.Token)))
i += copy(dAtA[i:], m.Token)
}
if len(m.Phrase) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintCaptcha(dAtA, i, uint64(len(m.Phrase)))
i += copy(dAtA[i:], m.Phrase)
}
return i, nil
}
func (m *CaptchaCheckResp) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *CaptchaCheckResp) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Code != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintCaptcha(dAtA, i, uint64(m.Code))
}
if len(m.Msg) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintCaptcha(dAtA, i, uint64(len(m.Msg)))
i += copy(dAtA[i:], m.Msg)
}
if len(m.Data) > 0 {
for k, _ := range m.Data {
dAtA[i] = 0x1a
i++
v := m.Data[k]
mapSize := 1 + sovCaptcha(uint64(k)) + 1 + sovCaptcha(uint64(v))
i = encodeVarintCaptcha(dAtA, i, uint64(mapSize))
dAtA[i] = 0x8
i++
i = encodeVarintCaptcha(dAtA, i, uint64(k))
dAtA[i] = 0x10
i++
i = encodeVarintCaptcha(dAtA, i, uint64(v))
}
}
return i, nil
}
func encodeVarintCaptcha(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *CaptchaCheckReq) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Token)
if l > 0 {
n += 1 + l + sovCaptcha(uint64(l))
}
l = len(m.Phrase)
if l > 0 {
n += 1 + l + sovCaptcha(uint64(l))
}
return n
}
func (m *CaptchaCheckResp) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Code != 0 {
n += 1 + sovCaptcha(uint64(m.Code))
}
l = len(m.Msg)
if l > 0 {
n += 1 + l + sovCaptcha(uint64(l))
}
if len(m.Data) > 0 {
for k, v := range m.Data {
_ = k
_ = v
mapEntrySize := 1 + sovCaptcha(uint64(k)) + 1 + sovCaptcha(uint64(v))
n += mapEntrySize + 1 + sovCaptcha(uint64(mapEntrySize))
}
}
return n
}
func sovCaptcha(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozCaptcha(x uint64) (n int) {
return sovCaptcha(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *CaptchaCheckReq) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: CaptchaCheckReq: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: CaptchaCheckReq: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Token = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Phrase", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Phrase = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipCaptcha(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCaptcha
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *CaptchaCheckResp) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: CaptchaCheckResp: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: CaptchaCheckResp: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
}
m.Code = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Code |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Msg = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Data == nil {
m.Data = make(map[int64]int64)
}
var mapkey int64
var mapvalue int64
for iNdEx < postIndex {
entryPreIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
if fieldNum == 1 {
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
mapkey |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
} else if fieldNum == 2 {
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
mapvalue |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
} else {
iNdEx = entryPreIndex
skippy, err := skipCaptcha(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCaptcha
}
if (iNdEx + skippy) > postIndex {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
m.Data[mapkey] = mapvalue
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipCaptcha(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCaptcha
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipCaptcha(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthCaptcha
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipCaptcha(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthCaptcha = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowCaptcha = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("v0/Captcha.proto", fileDescriptor_Captcha_715baa8051ae2c15) }
var fileDescriptor_Captcha_715baa8051ae2c15 = []byte{
// 323 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0x3f, 0x4f, 0x3a, 0x41,
0x10, 0x65, 0x59, 0xfe, 0xfc, 0x98, 0x5f, 0x21, 0xd9, 0x58, 0x20, 0x92, 0x3d, 0x42, 0x61, 0x68,
0x3c, 0x08, 0x16, 0x1a, 0xcb, 0x03, 0x4b, 0x9b, 0x2d, 0x2c, 0xec, 0x96, 0x65, 0xbd, 0x33, 0x08,
0x7b, 0xc0, 0x72, 0x09, 0xdf, 0xc2, 0x8f, 0x65, 0xac, 0x28, 0xad, 0x2e, 0x86, 0xeb, 0xee, 0x53,
0x98, 0xdb, 0xdd, 0x68, 0x34, 0xd1, 0x66, 0x66, 0xde, 0xec, 0xcc, 0x7b, 0x6f, 0xb2, 0xd0, 0x4c,
0x86, 0x83, 0x31, 0x8f, 0xb5, 0x88, 0xb8, 0x1f, 0xaf, 0x95, 0x56, 0x04, 0x84, 0x83, 0xc9, 0xb0,
0x7d, 0x1e, 0x3e, 0xea, 0x68, 0x3b, 0xf5, 0x85, 0x5a, 0x0c, 0x42, 0x15, 0xaa, 0x81, 0x19, 0x99,
0x6e, 0x1f, 0x0c, 0x32, 0xc0, 0x54, 0x76, 0xb5, 0x77, 0x07, 0x47, 0x8e, 0x6b, 0x1c, 0x49, 0x31,
0x67, 0x72, 0x45, 0x3c, 0xa8, 0x6a, 0x35, 0x97, 0xcb, 0x16, 0xea, 0xa2, 0x7e, 0x23, 0x68, 0xe4,
0xa9, 0x67, 0x1b, 0xcc, 0x26, 0xd2, 0x83, 0x5a, 0x1c, 0xad, 0xf9, 0x46, 0xb6, 0xca, 0x66, 0x02,
0xf2, 0xd4, 0x73, 0x1d, 0xe6, 0x72, 0xef, 0x15, 0x41, 0xf3, 0x3b, 0xf1, 0x26, 0x26, 0x1d, 0xa8,
0x08, 0x35, 0x93, 0x86, 0x18, 0x07, 0xff, 0xf2, 0xd4, 0x33, 0x98, 0x99, 0x48, 0x4e, 0x00, 0x2f,
0x36, 0xa1, 0xe3, 0xac, 0xe7, 0xa9, 0x57, 0x40, 0x56, 0x04, 0x32, 0x81, 0xca, 0x8c, 0x6b, 0xde,
0xc2, 0x5d, 0xdc, 0xff, 0x3f, 0x3a, 0xf3, 0xbf, 0xee, 0xf5, 0x7f, 0x8a, 0xf8, 0x13, 0xae, 0xf9,
0xcd, 0x52, 0xaf, 0x77, 0x56, 0xa0, 0xd8, 0x63, 0x26, 0xb6, 0x2f, 0xa1, 0xf1, 0xf9, 0x48, 0x9a,
0x80, 0xe7, 0x72, 0x67, 0xad, 0xb0, 0xa2, 0x24, 0xc7, 0x50, 0x4d, 0xf8, 0xd3, 0xd6, 0x5e, 0x85,
0x99, 0x05, 0xd7, 0xe5, 0x2b, 0x34, 0xba, 0x85, 0xba, 0x93, 0x21, 0x01, 0x54, 0x45, 0x21, 0x45,
0x4e, 0x7f, 0x37, 0xb1, 0x6a, 0x77, 0xfe, 0x72, 0x18, 0x74, 0x5e, 0x0e, 0x14, 0xed, 0x0f, 0x14,
0xbd, 0x1f, 0x28, 0x7a, 0xce, 0x68, 0x69, 0x9f, 0xd1, 0xd2, 0x5b, 0x46, 0x4b, 0xf7, 0xe5, 0x64,
0x38, 0xad, 0x99, 0x8f, 0xb9, 0xf8, 0x08, 0x00, 0x00, 0xff, 0xff, 0xa1, 0x9e, 0xe4, 0x4c, 0xe7,
0x01, 0x00, 0x00,
}

View File

@@ -0,0 +1,33 @@
syntax = "proto3";
package captcha.v0;
option go_package = "v0";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
service Captcha {
/** 校验验证码
*
*/
rpc check (CaptchaCheckReq) returns (CaptchaCheckResp);
}
message CaptchaCheckReq {
// token值
string token = 1 [(gogoproto.jsontag) = "token"];
// 输入值
string phrase = 2 [(gogoproto.jsontag) = "phrase"];
}
message CaptchaCheckResp {
// code
int64 code = 1 [(gogoproto.jsontag) = "code"];
// msg
string msg = 2 [(gogoproto.jsontag) = "msg"];
//
map<int64, int64> data = 3 [(gogoproto.jsontag) = "data"];
}

View File

@@ -0,0 +1,56 @@
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 = ["Captcha.proto"],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "v1_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_grpc"],
importpath = "go-common/app/service/live/captcha/api/liverpc/v1",
proto = ":v1_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = ["Captcha.liverpc.go"],
embed = [":v1_go_proto"],
importpath = "go-common/app/service/live/captcha/api/liverpc/v1",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/net/rpc/liverpc:go_default_library",
"@com_github_gogo_protobuf//gogoproto: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: v1/Captcha.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/Captcha.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:
// =================
// Captcha Interface
// =================
type CaptchaRPCClient interface {
// * 创建图片数字验证码
//
Create(ctx context.Context, req *CaptchaCreateReq, opts ...liverpc.CallOption) (resp *CaptchaCreateResp, err error)
}
// =======================
// Captcha Live Rpc Client
// =======================
type captchaRPCClient struct {
client *liverpc.Client
}
// NewCaptchaRPCClient creates a client that implements the CaptchaRPCClient interface.
func NewCaptchaRPCClient(client *liverpc.Client) CaptchaRPCClient {
return &captchaRPCClient{
client: client,
}
}
func (c *captchaRPCClient) Create(ctx context.Context, in *CaptchaCreateReq, opts ...liverpc.CallOption) (*CaptchaCreateResp, error) {
out := new(CaptchaCreateResp)
err := doRPCRequest(ctx, c.client, 1, "Captcha.create", 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
}

View File

@@ -0,0 +1,827 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: v1/Captcha.proto
package v1
import proto "github.com/gogo/protobuf/proto"
import fmt "fmt"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
import io "io"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// This is a compile-time assertion to ensure that this generated file
// is compatible with the proto package it is being compiled against.
// A compilation error at this line likely means your copy of the
// proto package needs to be updated.
const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type CaptchaCreateReq struct {
// 宽度
Width int64 `protobuf:"varint,1,opt,name=width,proto3" json:"width"`
// 高度
Height int64 `protobuf:"varint,2,opt,name=height,proto3" json:"height"`
}
func (m *CaptchaCreateReq) Reset() { *m = CaptchaCreateReq{} }
func (m *CaptchaCreateReq) String() string { return proto.CompactTextString(m) }
func (*CaptchaCreateReq) ProtoMessage() {}
func (*CaptchaCreateReq) Descriptor() ([]byte, []int) {
return fileDescriptor_Captcha_a2a8548161d89a91, []int{0}
}
func (m *CaptchaCreateReq) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CaptchaCreateReq) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CaptchaCreateReq.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *CaptchaCreateReq) XXX_Merge(src proto.Message) {
xxx_messageInfo_CaptchaCreateReq.Merge(dst, src)
}
func (m *CaptchaCreateReq) XXX_Size() int {
return m.Size()
}
func (m *CaptchaCreateReq) XXX_DiscardUnknown() {
xxx_messageInfo_CaptchaCreateReq.DiscardUnknown(m)
}
var xxx_messageInfo_CaptchaCreateReq proto.InternalMessageInfo
func (m *CaptchaCreateReq) GetWidth() int64 {
if m != nil {
return m.Width
}
return 0
}
func (m *CaptchaCreateReq) GetHeight() int64 {
if m != nil {
return m.Height
}
return 0
}
type CaptchaCreateResp struct {
// code
Code int64 `protobuf:"varint,1,opt,name=code,proto3" json:"code"`
// msg
Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg"`
//
Data *CaptchaCreateResp_Data `protobuf:"bytes,3,opt,name=data" json:"data"`
}
func (m *CaptchaCreateResp) Reset() { *m = CaptchaCreateResp{} }
func (m *CaptchaCreateResp) String() string { return proto.CompactTextString(m) }
func (*CaptchaCreateResp) ProtoMessage() {}
func (*CaptchaCreateResp) Descriptor() ([]byte, []int) {
return fileDescriptor_Captcha_a2a8548161d89a91, []int{1}
}
func (m *CaptchaCreateResp) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CaptchaCreateResp) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CaptchaCreateResp.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *CaptchaCreateResp) XXX_Merge(src proto.Message) {
xxx_messageInfo_CaptchaCreateResp.Merge(dst, src)
}
func (m *CaptchaCreateResp) XXX_Size() int {
return m.Size()
}
func (m *CaptchaCreateResp) XXX_DiscardUnknown() {
xxx_messageInfo_CaptchaCreateResp.DiscardUnknown(m)
}
var xxx_messageInfo_CaptchaCreateResp proto.InternalMessageInfo
func (m *CaptchaCreateResp) GetCode() int64 {
if m != nil {
return m.Code
}
return 0
}
func (m *CaptchaCreateResp) GetMsg() string {
if m != nil {
return m.Msg
}
return ""
}
func (m *CaptchaCreateResp) GetData() *CaptchaCreateResp_Data {
if m != nil {
return m.Data
}
return nil
}
type CaptchaCreateResp_Data struct {
//
Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token"`
//
Image string `protobuf:"bytes,2,opt,name=image,proto3" json:"image"`
}
func (m *CaptchaCreateResp_Data) Reset() { *m = CaptchaCreateResp_Data{} }
func (m *CaptchaCreateResp_Data) String() string { return proto.CompactTextString(m) }
func (*CaptchaCreateResp_Data) ProtoMessage() {}
func (*CaptchaCreateResp_Data) Descriptor() ([]byte, []int) {
return fileDescriptor_Captcha_a2a8548161d89a91, []int{1, 0}
}
func (m *CaptchaCreateResp_Data) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *CaptchaCreateResp_Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_CaptchaCreateResp_Data.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalTo(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (dst *CaptchaCreateResp_Data) XXX_Merge(src proto.Message) {
xxx_messageInfo_CaptchaCreateResp_Data.Merge(dst, src)
}
func (m *CaptchaCreateResp_Data) XXX_Size() int {
return m.Size()
}
func (m *CaptchaCreateResp_Data) XXX_DiscardUnknown() {
xxx_messageInfo_CaptchaCreateResp_Data.DiscardUnknown(m)
}
var xxx_messageInfo_CaptchaCreateResp_Data proto.InternalMessageInfo
func (m *CaptchaCreateResp_Data) GetToken() string {
if m != nil {
return m.Token
}
return ""
}
func (m *CaptchaCreateResp_Data) GetImage() string {
if m != nil {
return m.Image
}
return ""
}
func init() {
proto.RegisterType((*CaptchaCreateReq)(nil), "captcha.v1.CaptchaCreateReq")
proto.RegisterType((*CaptchaCreateResp)(nil), "captcha.v1.CaptchaCreateResp")
proto.RegisterType((*CaptchaCreateResp_Data)(nil), "captcha.v1.CaptchaCreateResp.Data")
}
func (m *CaptchaCreateReq) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *CaptchaCreateReq) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Width != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintCaptcha(dAtA, i, uint64(m.Width))
}
if m.Height != 0 {
dAtA[i] = 0x10
i++
i = encodeVarintCaptcha(dAtA, i, uint64(m.Height))
}
return i, nil
}
func (m *CaptchaCreateResp) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *CaptchaCreateResp) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if m.Code != 0 {
dAtA[i] = 0x8
i++
i = encodeVarintCaptcha(dAtA, i, uint64(m.Code))
}
if len(m.Msg) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintCaptcha(dAtA, i, uint64(len(m.Msg)))
i += copy(dAtA[i:], m.Msg)
}
if m.Data != nil {
dAtA[i] = 0x1a
i++
i = encodeVarintCaptcha(dAtA, i, uint64(m.Data.Size()))
n1, err := m.Data.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n1
}
return i, nil
}
func (m *CaptchaCreateResp_Data) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalTo(dAtA)
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *CaptchaCreateResp_Data) MarshalTo(dAtA []byte) (int, error) {
var i int
_ = i
var l int
_ = l
if len(m.Token) > 0 {
dAtA[i] = 0xa
i++
i = encodeVarintCaptcha(dAtA, i, uint64(len(m.Token)))
i += copy(dAtA[i:], m.Token)
}
if len(m.Image) > 0 {
dAtA[i] = 0x12
i++
i = encodeVarintCaptcha(dAtA, i, uint64(len(m.Image)))
i += copy(dAtA[i:], m.Image)
}
return i, nil
}
func encodeVarintCaptcha(dAtA []byte, offset int, v uint64) int {
for v >= 1<<7 {
dAtA[offset] = uint8(v&0x7f | 0x80)
v >>= 7
offset++
}
dAtA[offset] = uint8(v)
return offset + 1
}
func (m *CaptchaCreateReq) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Width != 0 {
n += 1 + sovCaptcha(uint64(m.Width))
}
if m.Height != 0 {
n += 1 + sovCaptcha(uint64(m.Height))
}
return n
}
func (m *CaptchaCreateResp) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Code != 0 {
n += 1 + sovCaptcha(uint64(m.Code))
}
l = len(m.Msg)
if l > 0 {
n += 1 + l + sovCaptcha(uint64(l))
}
if m.Data != nil {
l = m.Data.Size()
n += 1 + l + sovCaptcha(uint64(l))
}
return n
}
func (m *CaptchaCreateResp_Data) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.Token)
if l > 0 {
n += 1 + l + sovCaptcha(uint64(l))
}
l = len(m.Image)
if l > 0 {
n += 1 + l + sovCaptcha(uint64(l))
}
return n
}
func sovCaptcha(x uint64) (n int) {
for {
n++
x >>= 7
if x == 0 {
break
}
}
return n
}
func sozCaptcha(x uint64) (n int) {
return sovCaptcha(uint64((x << 1) ^ uint64((int64(x) >> 63))))
}
func (m *CaptchaCreateReq) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: CaptchaCreateReq: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: CaptchaCreateReq: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Width", wireType)
}
m.Width = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Width |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType)
}
m.Height = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Height |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipCaptcha(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCaptcha
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *CaptchaCreateResp) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: CaptchaCreateResp: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: CaptchaCreateResp: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType)
}
m.Code = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Code |= (int64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Msg", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Msg = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Data == nil {
m.Data = &CaptchaCreateResp_Data{}
}
if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipCaptcha(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCaptcha
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *CaptchaCreateResp_Data) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: Data: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Data: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Token", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Token = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Image", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowCaptcha
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthCaptcha
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Image = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipCaptcha(dAtA[iNdEx:])
if err != nil {
return err
}
if skippy < 0 {
return ErrInvalidLengthCaptcha
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func skipCaptcha(dAtA []byte) (n int, err error) {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
wireType := int(wire & 0x7)
switch wireType {
case 0:
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
iNdEx++
if dAtA[iNdEx-1] < 0x80 {
break
}
}
return iNdEx, nil
case 1:
iNdEx += 8
return iNdEx, nil
case 2:
var length int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
length |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLengthCaptcha
}
return iNdEx, nil
case 3:
for {
var innerWire uint64
var start int = iNdEx
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return 0, ErrIntOverflowCaptcha
}
if iNdEx >= l {
return 0, io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
innerWire |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
innerWireType := int(innerWire & 0x7)
if innerWireType == 4 {
break
}
next, err := skipCaptcha(dAtA[start:])
if err != nil {
return 0, err
}
iNdEx = start + next
}
return iNdEx, nil
case 4:
return iNdEx, nil
case 5:
iNdEx += 4
return iNdEx, nil
default:
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
}
}
panic("unreachable")
}
var (
ErrInvalidLengthCaptcha = fmt.Errorf("proto: negative length found during unmarshaling")
ErrIntOverflowCaptcha = fmt.Errorf("proto: integer overflow")
)
func init() { proto.RegisterFile("v1/Captcha.proto", fileDescriptor_Captcha_a2a8548161d89a91) }
var fileDescriptor_Captcha_a2a8548161d89a91 = []byte{
// 315 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x51, 0x4d, 0x4f, 0xc2, 0x40,
0x14, 0x64, 0x01, 0x41, 0x9e, 0x17, 0xdc, 0x13, 0x12, 0xdc, 0x92, 0x9e, 0xb8, 0x58, 0x02, 0xfe,
0x01, 0x03, 0x9a, 0x78, 0x34, 0x7b, 0x31, 0xf1, 0xb6, 0x94, 0x75, 0xdb, 0x18, 0x5c, 0x3e, 0x96,
0xfa, 0x37, 0xfc, 0x59, 0x1e, 0x39, 0x72, 0x6a, 0x4c, 0x7b, 0xeb, 0xaf, 0x30, 0xfb, 0x76, 0x13,
0x13, 0x4d, 0xb8, 0xbc, 0xe9, 0x4c, 0x66, 0xe7, 0xcd, 0x4b, 0xa1, 0x9b, 0x4d, 0xc6, 0x73, 0xb1,
0x36, 0x71, 0x22, 0xa2, 0xf5, 0x56, 0x1b, 0x4d, 0x21, 0xf6, 0x34, 0x9b, 0xf4, 0x6f, 0x54, 0x6a,
0x92, 0xfd, 0x22, 0x8a, 0xf5, 0x6a, 0xac, 0xb4, 0xd2, 0x63, 0xb4, 0x2c, 0xf6, 0xaf, 0xc8, 0x90,
0xe0, 0x97, 0x7b, 0x1a, 0x3e, 0x43, 0xd7, 0x67, 0xcd, 0xb7, 0x52, 0x18, 0xc9, 0xe5, 0x86, 0x06,
0x70, 0xf6, 0x91, 0x2e, 0x4d, 0xd2, 0x23, 0x43, 0x32, 0x6a, 0xcc, 0x3a, 0x55, 0x1e, 0x38, 0x81,
0x3b, 0xa0, 0x21, 0xb4, 0x12, 0x99, 0xaa, 0xc4, 0xf4, 0xea, 0xe8, 0x80, 0x2a, 0x0f, 0xbc, 0xc2,
0x3d, 0x86, 0x47, 0x02, 0x97, 0x7f, 0x92, 0x77, 0x6b, 0x3a, 0x80, 0x66, 0xac, 0x97, 0xd2, 0x27,
0x9f, 0x57, 0x79, 0x80, 0x9c, 0xe3, 0xa4, 0x57, 0xd0, 0x58, 0xed, 0x14, 0x86, 0x76, 0x66, 0xed,
0x2a, 0x0f, 0x2c, 0xe5, 0x76, 0xd0, 0x3b, 0x68, 0x2e, 0x85, 0x11, 0xbd, 0xc6, 0x90, 0x8c, 0x2e,
0xa6, 0x61, 0xf4, 0x7b, 0x71, 0xf4, 0x6f, 0x4b, 0x74, 0x2f, 0x8c, 0x70, 0xe1, 0xf6, 0x0d, 0xc7,
0xd9, 0x7f, 0x84, 0xa6, 0xd5, 0xed, 0x75, 0x46, 0xbf, 0xc9, 0x77, 0xec, 0xd0, 0x71, 0xd7, 0xa1,
0xc0, 0x1d, 0x58, 0x43, 0xba, 0x12, 0x4a, 0xfa, 0x1e, 0x68, 0x40, 0x81, 0x3b, 0x98, 0x3e, 0x41,
0xdb, 0xef, 0xa4, 0x0f, 0xd0, 0x8a, 0x71, 0x2f, 0x1d, 0x9c, 0xa8, 0xb4, 0xe9, 0x5f, 0x9f, 0x2c,
0x3c, 0x1b, 0x7c, 0x15, 0x8c, 0x1c, 0x0a, 0x46, 0xbe, 0x0b, 0x46, 0x3e, 0x4b, 0x56, 0x3b, 0x94,
0xac, 0x76, 0x2c, 0x59, 0xed, 0xa5, 0x9e, 0x4d, 0x16, 0x2d, 0xfc, 0x55, 0xb7, 0x3f, 0x01, 0x00,
0x00, 0xff, 0xff, 0xfa, 0xba, 0xd4, 0x22, 0xf9, 0x01, 0x00, 0x00,
}

Some files were not shown because too many files have changed in this diff Show More