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,44 @@
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 = ["answer-test.toml"],
importpath = "go-common/app/interface/main/answer/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/interface/main/answer/conf:go_default_library",
"//app/interface/main/answer/http:go_default_library",
"//library/ecode/tip:go_default_library",
"//library/log:go_default_library",
"//library/queue/databus/report:go_default_library",
"//library/text/translate/chinese: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,195 @@
# This is a TOML document. Boom.
version = "1.0.0"
[bm]
addr = "0.0.0.0:6991"
timeout = "1s"
[rpcClient]
[rpcClient.member]
timeout = "1s"
[rpcClient.account]
timeout = "10s"
[mysql]
addr = "127.0.0.1:3306"
dsn = "root:123456@tcp(127.0.0.1:3306)/bilibili_answer?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
idleTimeout ="4h"
queryTimeout = "1000ms"
execTimeout = "1000ms"
tranTimeout = "2000ms"
[mysql.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[memcache]
name = "answer"
proto = "tcp"
addr = "172.18.33.60:11234"
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "24h"
answerBolckExpire = "12h"
[redis]
name = "answer"
proto = "tcp"
addr = "127.0.0.1:6379"
idle = 10
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
expire = "720h"
ansCountExpire = "12h"
ansAddFlagCountExpire = "1m"
[Captcha]
key = "c1a1cb2d89c33794"
secret = "dda47eeca111e03e6845017505baea13"
dial = "500ms"
timeout = "1s"
keepAlive = "60s"
timer = 1000
[Captcha.breaker]
window ="3s"
sleep ="100ms"
bucket = 10
ratio = 0.5
request = 100
[httpClient]
[httpClient.normal]
dial = "1s"
timeout = "1s"
keepAlive = "60s"
timer = 10
key = "53e2fa226f5ad348"
secret = "3cf6bd1b0ff671021da5f424fea4b04a"
[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 = "zxnh4k92dwe61t27"
secret = "dnu3bwpxyswqwf1ixpsczthury1nqiew"
[httpClient.slow.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[host]
api = "http://api.bilibili.co"
geetest = "http://api.geetest.com"
account = "http://account.bilibili.com"
extraIds = "http://172.18.33.147:3000/laogai/question/exam/danmu"
[geetest]
[geetest.PC]
captchaId = "a703e7d11eda930ca87be02c1a80ff97"
privateKey = "df5eacf78b4afc79a052f199939e946a"
[geetest.H5]
captchaId = "bf666f87e5cca24ddb4c1dbeb70912b8"
privateKey = "d1e0bc5eadc754f8cd522c6fed5e175d"
[infoc2]
taskID = "000078"
proto = "tcp"
addr = "172.19.100.20:5401"
chanSize = 1024
[dataBus]
[dataBus.extraAnswer]
key = "0QEO9F8JuuIxZzNDvklH"
secret= "0QEO9F8JuuIxZzNDvklI"
group= "AccAnswer-BigData-P"
topic= "AccAnswer-T"
action="pub"
name = "answer-interface/databus"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
[dataBus.accountFormal]
key = "875d05ffa843e297"
secret= "24d052bae2247fc59ee925d46ffd61e2"
group= "Answer-MainAccountLaw-P"
topic= "Answer-T"
action="pub"
name = "answer-interface/databus"
proto = "tcp"
addr = "172.16.33.158:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
[antispam]
on=true
second=2
n=1
hour=12
m=5
[antispam.redis]
name = "answer"
proto = "tcp"
addr = "172.16.33.54:6379"
idle = 100
active = 100
dialTimeout = "500ms"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "80s"
expire = "10m"
[answer]
debug=true
duration=30
blockedTimestamp=0
baseNum = 4
proNum = 5
baseExtraPassNum=5
baseExtraNoPassNum=5
baseExtraScore=2
baseExtraPassCount=3
extraNum = 10
maxRetries = 10
captchaTokenURL = "http://api.bilibili.co/x/internal/v1/captcha/token"
captchaVerifyURL = "http://api.bilibili.co/x/internal/v1/captcha/verify"
[question]
tcQestTick = "1m"
rankQestTick = "10m"
[backoff]
maxDelay = 60
baseDelay = 5
factor = 1.6
jitter = 0.2

View File

@@ -0,0 +1,47 @@
package main
import (
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/interface/main/answer/conf"
"go-common/app/interface/main/answer/http"
ecode "go-common/library/ecode/tip"
"go-common/library/log"
"go-common/library/queue/databus/report"
"go-common/library/text/translate/chinese"
)
func main() {
flag.Parse()
if err := conf.Init(); err != nil {
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
ecode.Init(conf.Conf.Ecode)
chinese.Init()
http.Init(conf.Conf)
report.InitUser(conf.Conf.Report)
// signal handler
log.Info("answer-interface start")
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("answer get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGSTOP, syscall.SIGINT:
time.Sleep(time.Second * 2)
log.Info("answer-interface exit")
return
case syscall.SIGHUP:
// TODO reload
default:
return
}
}
}