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,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 = ["up_test.go"],
embed = [":go_default_library"],
tags = ["automanaged"],
deps = ["//app/service/main/up/model:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = ["up.go"],
importpath = "go-common/app/service/main/up/api/gorpc",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/up/model:go_default_library",
"//library/net/rpc: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,78 @@
package client
import (
"context"
"go-common/app/service/main/up/model"
"go-common/library/net/rpc"
)
const (
_Special = "RPC.Special"
_Info = "RPC.Info"
_UpStatBase = "RPC.UpStatBase"
_SetUpSwitch = "RPC.SetUpSwitch"
_UpSwitch = "RPC.UpSwitch"
)
const (
_appid = "archive.service.up"
)
var (
// _noRes = &struct{}{}
)
// Service rpc client
type Service struct {
client *rpc.Client2
}
// RPC rpc
type RPC interface {
// DEPRECATED: Please use gRPC service of func UpGroupMids instead, but must get datas in many times by one time of max 1000.
Special(c context.Context, arg *model.ArgSpecial) (res []*model.UpSpecial, err error)
// DEPRECATED: Please use gRPC service of func UpAttr instead.
Info(c context.Context, arg *model.ArgInfo) (res *model.UpInfo, err error)
}
// New create
func New(c *rpc.ClientConfig) (s *Service) {
s = &Service{}
s.client = rpc.NewDiscoveryCli(_appid, c)
return
}
// Special special
// DEPRECATED: Please use gRPC service of func UpGroupMids instead, but must get datas in many times by one time of max 1000.
func (s *Service) Special(c context.Context, arg *model.ArgSpecial) (res []*model.UpSpecial, err error) {
err = s.client.Call(c, _Special, arg, &res)
return
}
// Info info
// DEPRECATED: Please use gRPC service of func UpAttr instead.
func (s *Service) Info(c context.Context, arg *model.ArgInfo) (res *model.UpInfo, err error) {
err = s.client.Call(c, _Info, arg, &res)
return
}
// UpStatBase base statis
// DEPRECATED: Please use gRPC service func UpBaseStats instead.
func (s *Service) UpStatBase(c context.Context, arg *model.ArgMidWithDate) (res *model.UpBaseStat, err error) {
err = s.client.Call(c, _UpStatBase, arg, &res)
return
}
// SetUpSwitch set up switch
// DEPRECATED: Please use gRPC service func SetUpSwitch instead.
func (s *Service) SetUpSwitch(c context.Context, arg *model.ArgUpSwitch) (res *model.PBSetUpSwitchRes, err error) {
err = s.client.Call(c, _SetUpSwitch, arg, &res)
return
}
// UpSwitch get up switch
// DEPRECATED: Please use gRPC service func UpSwitch instead.
func (s *Service) UpSwitch(c context.Context, arg *model.ArgUpSwitch) (res *model.PBUpSwitch, err error) {
err = s.client.Call(c, _UpSwitch, arg, &res)
return
}

View File

@@ -0,0 +1,48 @@
package client
import (
"context"
"testing"
"time"
"go-common/app/service/main/up/model"
)
func TestRpcClient(t *testing.T) {
s := New(nil)
time.Sleep(1 * time.Second)
testInfo(t, s)
testSpecial(t, s)
testUpStatBase(t, s)
testUpSwitch(t, s)
}
func testInfo(t *testing.T, s *Service) {
arg := model.ArgInfo{
Mid: 2089809,
From: 1,
}
t.Log(s.Info(context.TODO(), &arg))
}
func testSpecial(t *testing.T, s *Service) {
arg := model.ArgSpecial{
GroupID: 1,
}
t.Log(s.Special(context.TODO(), &arg))
}
func testUpStatBase(t *testing.T, s *Service) {
arg := model.ArgMidWithDate{
Mid: 12345,
}
t.Log(s.UpStatBase(context.TODO(), &arg))
}
func testUpSwitch(t *testing.T, s *Service) {
arg := model.ArgUpSwitch{
Mid: 1,
From: 0,
}
t.Log(s.UpSwitch(context.TODO(), &arg))
}