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,46 @@
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 = ["member-service-example.toml"],
importpath = "go-common/app/service/main/member/cmd",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/member/conf:go_default_library",
"//app/service/main/member/server/gorpc:go_default_library",
"//app/service/main/member/server/grpc:go_default_library",
"//app/service/main/member/server/http:go_default_library",
"//app/service/main/member/service:go_default_library",
"//library/log:go_default_library",
"//library/net/trace:go_default_library",
"//library/queue/databus/report: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 main
import (
"context"
"flag"
"os"
"os/signal"
"syscall"
"time"
"go-common/app/service/main/member/conf"
"go-common/app/service/main/member/server/gorpc"
"go-common/app/service/main/member/server/grpc"
"go-common/app/service/main/member/server/http"
"go-common/app/service/main/member/service"
"go-common/library/log"
"go-common/library/net/trace"
"go-common/library/queue/databus/report"
)
func main() {
flag.Parse()
// init conf,log,trace,stat,perf.
if err := conf.Init(); err != nil {
panic(err)
}
log.Init(conf.Conf.Log)
defer log.Close()
trace.Init(conf.Conf.Tracer)
defer trace.Close()
report.InitUser(conf.Conf.ReportUser)
report.InitManager(conf.Conf.ReportManager)
svr := service.New(conf.Conf)
rpcSvr := gorpc.New(conf.Conf, svr)
ws := grpc.New(conf.Conf.WardenServer, svr)
http.Init(conf.Conf, svr)
// signal handler
log.Info("member-service start")
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP, syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT)
for {
s := <-c
log.Info("member-service get a signal %s", s.String())
switch s {
case syscall.SIGQUIT, syscall.SIGTERM, syscall.SIGINT:
ws.Shutdown(context.Background())
rpcSvr.Close()
time.Sleep(time.Second * 2)
log.Info("member-service exit")
return
case syscall.SIGHUP:
default:
return
}
}
}

View File

@@ -0,0 +1,157 @@
# This is a TOML document. Boom.
[xlog]
stdout=true
[rpcServer2]
[mysql]
addr = "172.16.33.205"
dsn = "test:test@tcp(172.16.33.205:3308)/bilibili_member?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 5
idle = 2
IdleTimeout ="4h"
queryTimeout = "100ms"
execTimeout = "100ms"
tranTimeout = "200ms"
[mysql.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[accMysql]
addr = "172.16.33.205:3306"
dsn = "account:wx2U1MwXRyWEuURw@tcp(172.16.33.205:3306)/account?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 50
idle = 5
idleTimeout = "4h"
queryTimeout = "2s"
execTimeout = "2s"
tranTimeout = "2s"
[accMysql.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[memcache]
name = "member-service"
proto = "tcp"
addr = "172.18.33.61:11219"
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
[cacheTTL]
baseTTL = "24h"
moralTTL = "24h"
captureTimesTTL = "1h"
captureCodeTTL = "5m"
captureErrTimesTTL = "5m"
applyInfoTTL = "5m"
[redis]
name = "member-service"
proto = "tcp"
addr = "127.0.0.1:6379"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
[httpClient]
key="7d9f6f6fe2a898e8"
secret= "4de2ccdbd9db69be0c2c6437bfe6eb69"
dial = "500ms"
timeout = "1s"
keepAlive = "60s"
timer = 10
[httpClient.breaker]
window = "3s"
sleep = "100ms"
bucket = 10
ratio = 0.5
request = 100
[databus]
key = "4ba46ba31f9a44ef"
secret = "e4c5a7fce28695209e6b4f0af8cf91c5"
group = "AccountLog-MainAccount-P"
topic = "AccountLog-T"
action = "pub"
name = "member-service/databus"
proto = "tcp"
addr = "172.18.33.50:6205"
idle = 100
active = 100
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[accountnotify]
key = "4ba46ba31f9a44ef"
secret = "e4c5a7fce28695209e6b4f0af8cf91c5"
group = "AccountNotify-MainAccount-P"
topic = "AccountNotify-T"
action = "pub"
buffer = 2048
name = "account-notify-job/databus"
proto = "tcp"
addr = "172.18.33.50:6205"
idle = 1
active = 1
dialTimeout = "1s"
readTimeout = "60s"
writeTimeout = "1s"
idleTimeout = "10s"
[wardenServer]
addr = "0.0.0.0:9000"
timeout = "1s"
[host]
search="http://uat-bili-search.bilibili.co"
[realnameProperty]
imgURLTemplate = "http://uat-manager.bilibili.co/x/admin/member/realname/image/preview?token=%s&border_size=800"
# block
[BlockMySQL]
addr = "172.16.33.205:3306"
dsn = "bilibili_block:NfAKk5h6ZMkx9o3EZPO2BIX3doCqXy6H@tcp(172.16.33.205:3306)/bilibili_block?timeout=5s&readTimeout=5s&writeTimeout=5s&parseTime=true&loc=Local&charset=utf8,utf8mb4"
active = 20
idle = 10
idleTimeout ="4h"
queryTimeout = "1s"
execTimeout = "1s"
tranTimeout = "1s"
[BlockMemcache]
name = "block-service"
proto = "tcp"
addr = "172.18.33.60:11233"
idle = 5
active = 10
dialTimeout = "1s"
readTimeout = "1s"
writeTimeout = "1s"
idleTimeout = "10s"
[blockCacheTTL]
userTTL = "80m"
userMaxRate = 20.0
# 越大延长概率越小
userT = 0.7
[BlockProperty]
msgURL = "http://message.bilibili.co/api/notify/send.user.notify.do"
whiteList = [2, 46333]