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,40 @@
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
"go_test",
)
go_library(
name = "go_default_library",
srcs = ["secure.go"],
importpath = "go-common/app/service/main/secure/rpc/client",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/secure/model:go_default_library",
"//library/net/rpc:go_default_library",
],
)
go_test(
name = "go_default_test",
srcs = ["secure_test.go"],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
deps = ["//app/service/main/secure/model: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,58 @@
package secure
import (
"context"
model "go-common/app/service/main/secure/model"
"go-common/library/net/rpc"
)
const (
_status = "RPC.Status"
_expect = "RPC.ExpectionLoc"
_addFeedback = "RPC.AddFeedBack"
_closeNotify = "RPC.CloseNotify"
)
const (
_appid = "account.service.secure"
)
var (
_noRes = &struct{}{}
)
// Service rpc service.
type Service struct {
client *rpc.Client2
}
// New new rpc service.
func New(c *rpc.ClientConfig) (s *Service) {
s = &Service{}
s.client = rpc.NewDiscoveryCli(_appid, c)
return
}
// Status get the ip info.
func (s *Service) Status(c context.Context, arg *model.ArgSecure) (res *model.Msg, err error) {
res = new(model.Msg)
err = s.client.Call(c, _status, arg, &res)
return
}
// CloseNotify clsoe notify.
func (s *Service) CloseNotify(c context.Context, arg *model.ArgSecure) (err error) {
return s.client.Call(c, _closeNotify, arg, &_noRes)
}
// AddFeedBack add expection feedback.
func (s *Service) AddFeedBack(c context.Context, arg *model.ArgFeedBack) (err error) {
return s.client.Call(c, _addFeedback, arg, &_noRes)
}
// ExpectionLoc get expection loc.
func (s *Service) ExpectionLoc(c context.Context, arg *model.ArgSecure) (res []*model.Expection, err error) {
err = s.client.Call(c, _expect, arg, &res)
return
}

View File

@@ -0,0 +1,35 @@
package secure
import (
"context"
"testing"
"time"
model "go-common/app/service/main/secure/model"
)
var s *Service
func TestSecure(t *testing.T) {
s = New(nil)
time.Sleep(1000 * time.Second)
testStatus(t)
testExpectionLoc(t)
}
// TestStatus test status rpc.
func testStatus(t *testing.T) {
if res, err := s.Status(context.TODO(), &model.ArgSecure{Mid: 1, UUID: "2"}); err != nil {
t.Errorf("Service: Status err: %v", err)
} else {
t.Logf("Service: Status res: %+v", res)
}
}
func testExpectionLoc(t *testing.T) {
if res, err := s.ExpectionLoc(context.TODO(), &model.ArgSecure{Mid: 1, UUID: "2"}); err != nil {
t.Errorf("Service : Expection err:%v", err)
} else {
t.Logf("Service: Status res: %+v", res)
}
}