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,49 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "cmd",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
data = ["test.toml"],
importpath = "go-common/app/service/bbq/recsys-recall/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/bbq/recsys-recall/conf:go_default_library",
"//app/service/bbq/recsys-recall/server/grpc:go_default_library",
"//app/service/bbq/recsys-recall/server/http:go_default_library",
"//app/service/bbq/recsys-recall/service:go_default_library",
"//app/service/bbq/recsys-recall/service/index:go_default_library",
"//library/ecode/tip:go_default_library",
"//library/log:go_default_library",
"//library/net/trace:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/bbq/recsys-recall/cmd/client:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,40 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_binary",
"go_library",
)
go_binary(
name = "client",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
importpath = "go-common/app/service/bbq/recsys-recall/cmd/client",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/bbq/recsys-recall/api/grpc/v1:go_default_library",
"//library/net/rpc/warden:go_default_library",
"//library/time: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,115 @@
package main
import (
"context"
"flag"
"fmt"
"log"
"time"
"go-common/app/service/bbq/recsys-recall/api/grpc/v1"
"go-common/library/net/rpc/warden"
xtime "go-common/library/time"
)
var (
addr string
)
func test1(client v1.RecsysRecallClient) {
var infos []*v1.RecallInfo
// infos = append(infos, &v1.RecallInfo{
// Tag: "HOT_T1:30",
// Name: "HOT",
// Priority: 1,
// Limit: 20,
// })
// infos = append(infos, &v1.RecallInfo{
// Tag: "RECALL:HOT_T:10053",
// Name: "op",
// Scorer: "default",
// Filter: "bloomfilter",
// Priority: 2,
// Limit: 10,
// })
infos = append(infos, &v1.RecallInfo{
Tag: "RECALL:HOT_T:92",
Name: "175",
Scorer: "default",
Filter: "bloomfilter",
Priority: 1,
Limit: 5,
})
// infos = append(infos, &v1.RecallInfo{
// Tag: "bbq:recall:tagid:11",
// Name: "11",
// Limit: 20,
// })
// infos = append(infos, &v1.RecallInfo{
// Tag: "bbq:recall:tagid:802",
// Name: "802",
// Limit: 20,
// })
// infos = append(infos, &v1.RecallInfo{
// Tag: "bbq:recall:tagid:159",
// Name: "159",
// Limit: 20,
// })
// infos = append(infos, &v1.RecallInfo{
// Tag: "bbq:recall:tagid:1604",
// Name: "1604",
// Priority: 20,
// Limit: 20,
// })
req := &v1.RecallRequest{
MID: 5829468,
BUVID: "d9972de637d2f3b8939ee628a7ea789b",
Infos: infos,
TotalLimit: 20,
}
resp, _ := client.Recall(context.Background(), req)
fmt.Println(resp)
// if err != nil {
// fmt.Println(err)
// return
// }
for _, v := range resp.List {
fmt.Println(v)
}
// for _, v := range resp.SrcInfo {
// fmt.Println(v)
// }
}
// func test2(client v1.RecsysRecallClient) {
// request := &v1.VideoIndexRequest{
// SVIDs: []int64{265375},
// }
// resp, err := client.VideoIndex(context.Background(), request)
// if err != nil {
// fmt.Println(err)
// return
// }
// fmt.Println(resp)
// }
func init() {
flag.StringVar(&addr, "addr", "127.0.0.1:9000", "server addr")
}
func main() {
flag.Parse()
cfg := &warden.ClientConfig{
Dial: xtime.Duration(time.Second * 3),
Timeout: xtime.Duration(time.Second * 3),
}
cc, err := warden.NewClient(cfg).Dial(context.Background(), addr)
if err != nil {
log.Fatalf("new client failed!err:=%v", err)
return
}
client := v1.NewRecsysRecallClient(cc)
test1(client)
// test2(client)
}

View File

@@ -0,0 +1,59 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"go-common/app/service/bbq/recsys-recall/conf"
"go-common/app/service/bbq/recsys-recall/server/grpc"
"go-common/app/service/bbq/recsys-recall/server/http"
"go-common/app/service/bbq/recsys-recall/service"
"go-common/app/service/bbq/recsys-recall/service/index"
ecode "go-common/library/ecode/tip"
"go-common/library/log"
"go-common/library/net/trace"
)
func main() {
// cpuf, err := os.Create("cpu_profile")
// if err != nil {
// panic(err)
// }
// pprof.StartCPUProfile(cpuf)
// defer pprof.StopCPUProfile()
flag.Parse()
if err := conf.Init(); err != nil {
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
log.Info("start")
trace.Init(conf.Conf.Tracer)
defer trace.Close()
ecode.Init(conf.Conf.Ecode)
srv := service.New(conf.Conf)
// 加载正排索引
index.Init(conf.Conf)
grpc.New(srv)
http.Init(conf.Conf)
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
log.Info("exit")
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

@@ -0,0 +1,91 @@
[log]
stdout = true
[bm]
addr = "0.0.0.0:8080"
timeout = "1s"
[mysql]
addr = "172.16.38.91:3306"
dsn = "root:123456@tcp(172.16.38.91:3306)/bbq?timeout=200ms&readTimeout=200ms&writeTimeout=200ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"
readDSN = ["root:123456@tcp(172.16.38.91:3306)/bbq?timeout=200ms&readTimeout=200ms&writeTimeout=200ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"]
active = 20
idle = 10
idleTimeout ="4h"
queryTimeout = "100ms"
execTimeout = "100ms"
tranTimeout = "200ms"
[redis]
name = "recsys-recall-service"
proto = "tcp"
addr = "172.16.38.91:6379"
idle = 10
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "1m"
[bfredis]
name = "recsys-recall-service"
proto = "tcp"
addr = "172.16.38.91:6379"
idle = 10
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "1m"
[httpClient]
[httpClient.normal]
dial = "1s"
timeout = "10s"
keepAlive = "60s"
timer = 10
key = "7c7ac0db1aa05587"
secret = "9a6d62d93290c5f771ad381e9ca23f26"
[httpClient.normal.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[httpClient.slow]
dial = "500ms"
timeout = "1s"
keepAlive = "60s"
timer = 10
key = "7c7ac0db1aa05587"
secret = "9a6d62d93290c5f771ad381e9ca23f26"
[httpClient.slow.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[workPool]
capacity = 1024
maxWorkers = 512
maxIdleWorkers = 256
minIdleWorkers = 128
keepAlive = "30s"
[forwardIndex]
localPath = "/Users/daiwei/Downloads/idx.txt"
remotePath = "http://172.16.38.91/fs/out.txt"
md5Path = "http://172.16.38.91/fs/out.md5"
protocol = "http"
reloadDucation = "1800s"
[localCache]
l1Tags = []
l2Tags = []
level1 = "300s"
level2 = "600s"
level3 = "900s"
maxAge = "1800s"