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,67 @@
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 = [
"//app/service/main/broadcast/model:model_proto",
"@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/main/broadcast/api/grpc/v1",
proto = ":v1_proto",
tags = ["manual"],
deps = [
"//app/service/main/broadcast/model:model_go_proto",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
],
)
go_library(
name = "go_default_library",
srcs = [
"api.go",
"client.go",
],
embed = [":v1_go_proto"],
importpath = "go-common/app/service/main/broadcast/api/grpc/v1",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/broadcast/model:go_default_library",
"//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"],
)

View File

@@ -0,0 +1,17 @@
package v1
import (
"fmt"
)
func (m *ConnectReq) String() string {
return fmt.Sprintf("server:%s serverKey:%s token:%s", m.Server, m.ServerKey, m.Token)
}
func (m *OnlineReq) String() string {
return fmt.Sprintf("server:%s", m.Server)
}
func (m *OnlineReply) String() string {
return fmt.Sprintf("rooms:%d", len(m.RoomCount))
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,119 @@
// +bili:type=service
// Code generated by warden.
syntax = "proto3";
package push.service.broadcast;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
import "app/service/main/broadcast/model/model.proto";
message CloseReply {
}
message CloseReq {
}
message PingReply {
}
message PingReq {
}
message ConnectReq {
option (gogoproto.goproto_stringer) = false;
string server = 1;
string serverKey = 2;
string cookie = 3;
bytes token = 4;
}
message ConnectReply {
int64 mid = 1;
string key = 2;
string roomID = 3;
string platform = 4;
repeated int32 accepts = 5;
}
message DisconnectReq {
int64 mid = 1;
string key = 2;
string server = 3;
}
message DisconnectReply {
bool has = 1;
}
message HeartbeatReq {
int64 mid = 1;
string key = 2;
string server = 3;
}
message HeartbeatReply {
}
message OnlineReq {
option (gogoproto.goproto_stringer) = false;
string server = 1;
map<string, int32> roomCount = 2;
int32 sharding = 3;
}
message OnlineReply {
option (gogoproto.goproto_stringer) = false;
map<string, int32> roomCount = 1;
}
message ReceiveReq {
int64 mid = 1;
push.service.broadcast.model.Proto proto = 2;
}
message ReceiveReply {
push.service.broadcast.model.Proto proto = 1;
}
message ServerListReq {
string platform = 1;
}
message ServerListReply {
string domain = 1 [(gogoproto.jsontag) = "domain"];
int32 tcpPort = 2 [(gogoproto.jsontag) = "tcp_port"];
int32 wsPort = 3 [(gogoproto.jsontag) = "ws_port"];
int32 wssPort = 4 [(gogoproto.jsontag) = "wss_port"];
int32 heartbeat = 5 [(gogoproto.jsontag) = "heartbeat"];
repeated string nodes = 6 [(gogoproto.jsontag) = "nodes"];
Backoff backoff = 7 [(gogoproto.jsontag) = "backoff"];
int32 heartbeatMax = 8 [(gogoproto.jsontag) = "heartbeat_max"];
}
message Backoff {
int32 MaxDelay = 1 [(gogoproto.jsontag) = "max_delay"];
int32 BaseDelay = 2 [(gogoproto.jsontag) = "base_delay"];
float Factor = 3 [(gogoproto.jsontag) = "factor"];
float Jitter = 4 [(gogoproto.jsontag) = "jitter"];
}
service Zerg {
// Ping Service
rpc Ping(PingReq) returns(PingReply);
// Close Service
rpc Close(CloseReq) returns(CloseReply);
// Connect
rpc Connect(ConnectReq) returns (ConnectReply);
// Disconnect
rpc Disconnect(DisconnectReq) returns (DisconnectReply);
// Heartbeat
rpc Heartbeat(HeartbeatReq) returns (HeartbeatReply);
// RenewOnline
rpc RenewOnline(OnlineReq) returns (OnlineReply);
// Receive
rpc Receive(ReceiveReq) returns (ReceiveReply);
//ServerList
rpc ServerList(ServerListReq) returns (ServerListReply);
}

View File

@@ -0,0 +1,24 @@
package v1
import (
"context"
"go-common/library/net/rpc/warden"
"google.golang.org/grpc"
)
// .
const (
DiscoveryID = "push.service.broadcast"
)
// NewClient .
func NewClient(conf *warden.ClientConfig, opts ...grpc.DialOption) (ZergClient, error) {
client := warden.NewClient(conf, opts...)
cc, err := client.Dial(context.Background(), "discovery://default/"+DiscoveryID)
if err != nil {
return nil, err
}
return NewZergClient(cc), nil
}