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,48 @@
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/search/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/bbq/search/conf:go_default_library",
"//app/service/bbq/search/server/grpc:go_default_library",
"//app/service/bbq/search/server/http:go_default_library",
"//app/service/bbq/search/service: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/search/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 = ["client.go"],
importpath = "go-common/app/service/bbq/search/cmd/client",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/bbq/search/api/grpc/v1:go_default_library",
"//app/service/bbq/search/model:go_default_library",
"@org_golang_google_grpc//: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,135 @@
package main
import (
"bytes"
"context"
"encoding/json"
"flag"
"fmt"
"go-common/app/service/bbq/search/api/grpc/v1"
"go-common/app/service/bbq/search/model"
"google.golang.org/grpc"
"os"
"time"
)
var (
serverAddr = flag.String("server_addr", "127.0.0.1:9000", "The server address in the format of host:port")
)
func main() {
conn, err := grpc.Dial(*serverAddr, grpc.WithInsecure())
if err != nil {
fmt.Println("11111", err)
return
}
defer conn.Close()
salesClient := v1.NewSearchClient(conn)
time1 := time.Now().UnixNano()
data := new(v1.SaveVideoRequest)
for i := 0; i < 1; i++ {
tmp := &v1.VideoESInfo{
SVID: int64(4 + i),
MID: 1,
CID: 1,
AVID: 1,
Title: "小姐姐 wo 好看 cityy" + string(i),
Content: "占位占位",
Pubtime: 12,
Duration: 0,
Original: 123,
State: 1,
From: 1,
VerID: 12,
Ver: "lasfjn123",
Ctime: 123,
Mtime: 123,
}
tags := make(map[int64]string)
//tags[1] = "舞蹈"
tags[2] = "直播"
//tags[3] = "开心"
for i, v := range tags {
tmp.Tags = append(tmp.Tags, &v1.VideoESTags{ID: i, Name: v})
}
data.List = append(data.List, tmp)
}
//res1,err := salesClient.SaveVideo(context.Background(), data)
//fmt.Println("CreateIndex",res1,err)
calc := &model.Calc{
Open: 1,
PlayRatio: 0.3,
FavRatio: 0.05,
LikeRatio: 0.15,
CoinRatio: 0.1,
ReplyRatio: 0.2,
ShareRatio: 0.1,
}
hotTags := []string{"美女"}
where := new(model.Where)
where.In = make(map[string][]interface{})
for _, tag := range hotTags {
where.In["tags.name"] = append(where.In["tags.name"], tag)
}
where.In["state"] = append(where.In["state"], 3)
where.NotIn = make(map[string][]interface{})
where.NotIn["avid"] = append(where.NotIn["avid"], 27035488)
where.Lte = make(map[string]int64)
where.Lte["svid"] = 1168
where.Gte = make(map[string]int64)
where.Gte["avid"] = 28457770
filter := make(map[string]interface{})
filter["buvid"] = "bbqtestbuvid"
filter["mid"] = 123
query := model.Query{
Calc: calc,
Where: where,
From: 0,
Size: 1,
Filter: filter,
}
queryBody, err := json.Marshal(query)
fmt.Println(query.Where)
fmt.Println(string(queryBody))
//del := new(v1.DelVideoBySVIDRequest)
//del.SVIDs = append(del.SVIDs, 84)
//res4, err := salesClient.DelVideoBySVID(context.Background(), del)
//fmt.Println(res4, err)
res3, err := salesClient.RecVideoData(context.Background(), &v1.RecVideoDataRequest{Query: string(queryBody)})
fmt.Println(res3)
fmt.Println(err)
//return
//res2,err := salesClient.RecVideoData(context.Background(), &v1.RecVideoDataRequest{PageNum:0,PageSize:2})
//res2,err := salesClient.RecVideoData(context.Background(), &v1.RecVideoDataRequest{Query:"{\"calc\":{\"open\":1,\"fav_ratio\":1.0,\"like_ratio\":0.5,\"pub_ratio\":0.3},\"where\":{\"in\":{\"title\":[\"舞蹈\",\"美女\"],\"tag.Name\":[\"小姐姐\"]}},\"limit\":2}"})
res2, err := salesClient.RecVideoData(context.Background(), &v1.RecVideoDataRequest{Query: string(queryBody)})
//res2,err := salesClient.RecVideoData(context.Background(), &v1.RecVideoDataRequest{Query:"{}"})
//fmt.Println("VideoData",res2,err)
var out bytes.Buffer
var b []byte
b, _ = json.Marshal(res2)
json.Indent(&out, b, "", "\t")
out.WriteTo(os.Stdout)
time2 := time.Now().UnixNano()
fmt.Println((time2 - time1) / 1e6)
//fmt.Println(queryBody)
//salesClientMis := v1.NewSalesMisClient(conn)
//
//
//res2,err := salesClientMis.GetGroupOrdersMis(context.Background(), &v1.GetGroupOrdersMisRequest{OrderID:0})
//fmt.Println("222",res2,err)
fmt.Println(err)
return
}

View File

@@ -0,0 +1,46 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"go-common/app/service/bbq/search/conf"
"go-common/app/service/bbq/search/server/grpc"
"go-common/app/service/bbq/search/server/http"
"go-common/app/service/bbq/search/service"
ecode "go-common/library/ecode/tip"
"go-common/library/log"
"go-common/library/net/trace"
)
func main() {
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)
grpc.New(srv)
http.Init(conf.Conf, srv)
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,41 @@
[log]
dir = "/data/log/bbq"
[bm]
addr = "0.0.0.0:8803"
timeout = "1s"
[mysql]
#addr = "127.0.0.1:3306"
#dsn = "root:123456@tcp(127.0.0.1:3306)/bbq?allowNativePasswords=true&timeout=200ms&readTimeout=200ms&writeTimeout=200ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"
#readDSN = ["root:123456@tcp(127.0.0.2:3306)/bbq?allowNativePasswords=true&timeout=200ms&readTimeout=200ms&writeTimeout=200ms&parseTime=true&loc=Local&charset=utf8,utf8mb4"]
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 = "search-service"
proto = "tcp"
addr = ""
idle = 10
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "1m"
[es]
[es.bbq]
addr = ["http://172.16.38.91:9200"]
timeout = "1s"
[es.cms]
addr = ["http://172.16.38.91:9200"]
timeout = "1s"