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

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
}