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,69 @@
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_test",
"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/main/identify-game/api/grpc/v1",
proto = ":v1_proto",
tags = ["automanaged"],
deps = ["@com_github_gogo_protobuf//gogoproto:go_default_library"],
)
go_test(
name = "go_default_test",
srcs = ["client_test.go"],
embed = [":go_default_library"],
tags = ["automanaged"],
deps = [
"//library/net/rpc/warden:go_default_library",
"//vendor/github.com/smartystreets/goconvey/convey:go_default_library",
],
)
go_library(
name = "go_default_library",
srcs = ["client.go"],
embed = [":v1_go_proto"],
importpath = "go-common/app/service/main/identify-game/api/grpc/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,43 @@
syntax = "proto3";
package main.service.identify.game.v1;
option go_package = "v1";
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
// DelCacheReq request param for rpc DelCache
message DelCacheReq {
string token = 1;
}
// DelCacheReply del cache reply
message DelCacheReply {
}
//
service IdentifyGame {
// CookieInfo identify info by cookie.
rpc DelCache (DelCacheReq) returns (DelCacheReply);
rpc GetCookieByToken(CreateCookieReq) returns (CreateCookieReply);
}
message CreateCookieReq {
string Token = 1 [(gogoproto.jsontag) = "token",(gogoproto.moretags) = "form:\"access_key\" validate:\"required\""];
string From = 2 [(gogoproto.jsontag) = "from",(gogoproto.moretags) = "form:\"from\""];
}
message CreateCookieReply {
CookieInfo BiliCookies = 1 [(gogoproto.jsontag) = "cookie_info"];
repeated string SSO = 2 [(gogoproto.jsontag) = "sso"];
}
message CookieInfo{
repeated Cookie Cookies = 1 [(gogoproto.jsontag) = "cookies"];
repeated string Domains = 2 [(gogoproto.jsontag) = "domains"];
}
message Cookie{
string Name = 1 [(gogoproto.jsontag) = "name"];
string Value = 2 [(gogoproto.jsontag) = "value"];
int64 HttpOnly = 3 [(gogoproto.jsontag) = "http_only"];
int64 Expires = 4 [(gogoproto.jsontag) = "expires"];
}

View File

@ -0,0 +1,22 @@
package v1
import (
"context"
"go-common/library/net/rpc/warden"
"google.golang.org/grpc"
)
// AppID unique app id for service discovery
const AppID = "identify.service.game"
// NewClient new identify grpc client
func NewClient(cfg *warden.ClientConfig, opts ...grpc.DialOption) (IdentifyGameClient, error) {
client := warden.NewClient(cfg, opts...)
conn, err := client.Dial(context.Background(), "discovery://default/"+AppID)
if err != nil {
return nil, err
}
return NewIdentifyGameClient(conn), nil
}

View File

@ -0,0 +1,31 @@
package v1
import (
"context"
"testing"
"go-common/library/net/rpc/warden"
. "github.com/smartystreets/goconvey/convey"
)
func TestClients_Post(t *testing.T) {
var (
ctx = context.Background()
err error
res *DelCacheReply
cookies *CreateCookieReply
)
Convey("test delete cache", t, func() {
client, _ := NewClient(&warden.ClientConfig{})
res, err = client.DelCache(ctx, &DelCacheReq{Token: "24325defrf"})
So(err, ShouldBeNil)
So(res, ShouldNotBeNil)
})
Convey("test get cookie by token", t, func() {
client, _ := NewClient(&warden.ClientConfig{})
cookies, err = client.GetCookieByToken(ctx, &CreateCookieReq{Token: "24325defrf"})
So(err, ShouldNotBeNil)
So(cookies, ShouldBeNil)
})
}