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_binary",
"go_library",
)
go_binary(
name = "cmd",
embed = [":go_default_library"],
tags = ["automanaged"],
)
go_library(
name = "go_default_library",
srcs = ["main.go"],
data = ["favorite-job-test.toml"],
importpath = "go-common/app/job/main/favorite/cmd",
tags = ["automanaged"],
deps = [
"//app/job/main/favorite/conf:go_default_library",
"//app/job/main/favorite/http:go_default_library",
"//app/job/main/favorite/service:go_default_library",
"//library/log: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,188 @@
# This is a TOML document. Boom.
[bm]
addr = "0.0.0.0:6016"
timeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
[fav]
maxPageSize = 50
cleanCDTime = "10s"
sleepTime = "200ms"
greyMod = 2126
whiteMids = [48222126,88888894]
[statMerge]
business = 2
target = 1
sources = [22,33]
[db]
[db.fav]
addr = "[favorite]tcp@172.16.33.205:3308"
dsn = "test:test@tcp(172.16.33.205:3308)/bilibili_fav?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 20
idle = 10
idleTimeout ="4h"
queryTimeout = "2s"
execTimeout = "2s"
tranTimeout = "2s"
[db.fav.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[db.read]
addr = "[favorite]tcp@172.16.33.205:3308"
dsn = "test:test@tcp(172.16.33.205:3308)/bilibili_fav?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 20
idle = 10
idleTimeout ="4h"
queryTimeout = "2s"
execTimeout = "2s"
tranTimeout = "2s"
[db.read.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[redis]
name = "favorite-job/favorite"
proto = "tcp"
addr = "172.18.33.61:6808"
idle = 100
active = 100
dialTimeout = "500ms"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"
expire = "10m"
ipExpire = "60s"
buvidExpire = "5m"
[memcache]
name = "favorite"
proto = "tcp"
addr = "172.18.33.61:11231"
idle = 10
active = 10
dialTimeout = "2s"
readTimeout = "2s"
writeTimeout = "2s"
idleTimeout = "7h"
expire = "15m"
[binlogDatabus]
key = "170e302355453683"
secret = "3d0e8db7bed0503949e545a469789279"
group = "Favorite-MainCommunity-S"
topic = "Favorite-T"
action = "sub"
name = "favorite-job/binlog"
proto = "tcp"
addr = "172.18.33.50:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[statFavDatabus]
key = "170e302355453683"
secret= "51b66df3ebeca2b08f0017f350b6f0ce"
group= "StatFav-MainCommunity-P"
topic= "StatFav-T"
action="pub"
name = "favorite-service/stat"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "1h"
[statFavDatabus.consumers]
"article"=1
"archive"=2
"playlist"=6
[jobDatabus]
key = "0QEO9F8JuuIxZzNDvklH"
secret= "0QEO9F8JuuIxZzNDvklI"
group= "FavoriteJob-UGC-S"
topic= "FavoriteJob-T"
action="sub"
name = "favorite/job"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "1h"
[favStatDatabus]
key = "170e302355453683"
secret = "51b66df3ebeca2b08f0017f350b6f0ce"
group = "StatFav-MainCommunity-S"
topic = "StatFav-T"
action = "sub"
name = "favorite-job/favStat"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[shareStatDatabus]
key = "170e302355453683"
secret = "51b66df3ebeca2b08f0017f350b6f0ce"
group = "StatShare-MainCommunity-S"
topic = "StatShare-T"
action = "sub"
name = "favorite-job/shareStat"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[mediaListCntDatabus]
key = "170e302355453683"
secret = "51b66df3ebeca2b08f0017f350b6f0ce"
group = "MediaListCnt-MainCommunity-S"
topic = "MediaListCnt-T"
action = "sub"
name = "favorite-job/playStat"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[rpcClient2]
[rpcClient2.coin]
timeout = "1s"
[rpcClient2.archive]
timeout = "1s"
[rpcClient2.article]
timeout = "1s"

View File

@ -0,0 +1,54 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"go-common/app/job/main/favorite/conf"
"go-common/app/job/main/favorite/http"
"go-common/app/job/main/favorite/service"
"go-common/library/log"
)
var (
s *service.Service
)
func main() {
flag.Parse()
if err := conf.Init(); err != nil {
log.Error("conf.Init() error(%v)", err)
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
log.Info("archive-service_consumer start")
s = service.New(conf.Conf)
http.Init(conf.Conf, s)
signalHandler()
}
func signalHandler() {
var (
err error
ch = make(chan os.Signal, 1)
)
signal.Notify(ch, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
si := <-ch
switch si {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
log.Info("get a signal %s, stop the consume process", si.String())
if err = s.Close(); err != nil {
log.Error("close consumer error(%v)", err)
}
s.Wait()
return
case syscall.SIGHUP:
default:
return
}
}
}