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,34 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["server.go"],
importpath = "go-common/app/service/main/open/server/grpc",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/open/api/grpc/v1:go_default_library",
"//app/service/main/open/service:go_default_library",
"//library/ecode:go_default_library",
"//library/net/rpc/warden: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,56 @@
// Package grpc generate by warden_gen
package grpc
import (
"context"
"go-common/app/service/main/open/api/grpc/v1"
"go-common/app/service/main/open/service"
"go-common/library/ecode"
"go-common/library/net/rpc/warden"
)
// New Open warden rpc server
func New(c *warden.ServerConfig, svr *service.Service) *warden.Server {
w := warden.NewServer(c)
v1.RegisterOpenServer(w.Server(), &openService{svr})
ws, err := w.Start()
if err != nil {
panic(err)
}
return ws
}
type openService struct {
svr *service.Service
}
var _ v1.OpenServer = &openService{}
// Ping check dao health.
func (s *openService) Ping(ctx context.Context, req *v1.PingReq) (*v1.PingReply, error) {
return nil, ecode.MethodNotAllowed
}
// Close close all dao.
func (s *openService) Close(ctx context.Context, req *v1.CloseReq) (*v1.CloseReply, error) {
return nil, ecode.MethodNotAllowed
}
// Secret .
func (s *openService) Secret(ctx context.Context, req *v1.SecretReq) (*v1.SecretReply, error) {
return nil, ecode.MethodNotAllowed
}
// AppID .
func (s *openService) AppID(ctx context.Context, req *v1.AppIDReq) (*v1.AppIDReply, error) {
appID, err := s.svr.AppID(ctx, req.AppKey)
if err != nil {
return nil, err
}
appIDReply := &v1.AppIDReply{
AppId: appID,
}
return appIDReply, nil
}